Skip to content

Commit 5284f6f

Browse files
authored
Merge pull request #13 from kdorr/fix-test-coverage
Fix test coverage
2 parents da0533a + 00c46ed commit 5284f6f

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
branch = true
33
source =
44
mplaltair
5-
omit = *tests*
65

76
[report]
87
exclude_lines =

mplaltair/tests/test_convert.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,17 @@ def test_convert_fill_fail():
131131
def test_quantitative_shape():
132132
chart = alt.Chart(df_quant).mark_point().encode(alt.Shape('shape'))
133133
mapping = convert(chart)
134-
assert list(mapping['marker']) == list(df_quant['shape'].values)
135134

136135
@pytest.mark.xfail(raises=NotImplementedError, reason="The marker argument in scatter() cannot take arrays")
137136
@pytest.mark.parametrize("column", ["years", "months", "days", "hrs", "combination"])
138137
def test_convert_shape_fail_temporal(column):
139138
chart = alt.Chart(df).mark_point().encode(alt.Shape(column))
140139
mapping = convert(chart)
141-
assert list(mapping['s']) == list(mdates.date2num(df[column].values))
142140

143141
@pytest.mark.xfail(raises=NotImplementedError, reason="Merge: the dtype for opacity isn't assumed to be quantitative")
144142
def test_quantitative_opacity_value():
145143
chart = alt.Chart(df_quant).mark_point().encode(opacity=alt.value(.5))
146144
mapping = convert(chart)
147-
assert mapping['alpha'] == 0.5
148145

149146
@pytest.mark.xfail(raises=NotImplementedError, reason="The alpha argument in scatter() cannot take arrays")
150147
def test_quantitative_opacity_array():
@@ -199,8 +196,6 @@ def test_quantitative_x_count_y():
199196
df_count = pd.DataFrame({"a": [1, 1, 2, 3, 5], "b": [1.4, 1.4, 2.9, 3.18, 5.3]})
200197
chart = alt.Chart(df_count).mark_point().encode(alt.X('a'), alt.Y('count()'))
201198
mapping = convert(chart)
202-
assert list(mapping['x']) == list(df_count['a'].values)
203-
assert list(mapping['y']) == list(df_count.groupby(['a']).count().values)
204199

205200
@pytest.mark.xfail(raises=NotImplementedError, reason="specifying timeUnit is not supported yet")
206201
def test_timeUnit():

mplaltair/tests/test_data.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,27 @@ def test_data_value_quantitative():
4141

4242

4343
@pytest.mark.parametrize("column", ['a', 'b', 'c'])
44-
@pytest.mark.xfail(raises=NotImplementedError)
45-
def test_data_aggregate_quantitative(column):
44+
def test_data_aggregate_quantitative_fail(column):
45+
""""'Passes' if it raises a NotImplementedError"""
4646
chart = alt.Chart(df).mark_point().encode(alt.X(field=column, type='quantitative', aggregate='average'))
4747
for channel in chart.to_dict()['encoding']:
48-
data = _data._locate_channel_data(chart, channel)
48+
with pytest.raises(NotImplementedError):
49+
data = _data._locate_channel_data(chart, channel)
4950

5051

51-
@pytest.mark.xfail(raises=NotImplementedError)
52-
def test_data_timeUnit_shorthand_temporal():
52+
def test_data_timeUnit_shorthand_temporal_fail():
5353
chart = alt.Chart(df).mark_point().encode(alt.X('month(combination):T'))
5454
for channel in chart.to_dict()['encoding']:
55-
data = _data._locate_channel_data(chart, channel)
55+
with pytest.raises(NotImplementedError):
56+
data = _data._locate_channel_data(chart, channel)
5657

5758

58-
@pytest.mark.xfail(raises=NotImplementedError)
59-
def test_data_timeUnit_field_temporal():
59+
def test_data_timeUnit_field_temporal_fail():
60+
""""'Passes' if it raises a NotImplementedError"""
6061
chart = alt.Chart(df).mark_point().encode(alt.X(field='combination', type='temporal', timeUnit='month'))
6162
for channel in chart.to_dict()['encoding']:
62-
data = _data._locate_channel_data(chart, channel)
63+
with pytest.raises(NotImplementedError):
64+
data = _data._locate_channel_data(chart, channel)
6365

6466

6567
# _locate_channel_dtype() tests
@@ -74,9 +76,9 @@ def test_data_dtype(column, expected):
7476
assert dtype == expected
7577

7678

77-
@pytest.mark.xfail(raises=NotImplementedError)
7879
def test_data_dtype_fail():
80+
""""'Passes' if it raises a NotImplementedError"""
7981
chart = alt.Chart(df).mark_point().encode(opacity=alt.value(.5))
8082
for channel in chart.to_dict()['encoding']:
81-
dtype = _data._locate_channel_dtype(chart, channel)
82-
assert dtype == 'quantitative'
83+
with pytest.raises(NotImplementedError):
84+
dtype = _data._locate_channel_dtype(chart, channel)

0 commit comments

Comments
 (0)