Skip to content

Commit 5d661c8

Browse files
jbrockmendeljreback
authored andcommitted
[TST] make xfails strict (#22139)
1 parent 8d5c51b commit 5d661c8

32 files changed

+111
-68
lines changed

pandas/tests/arrays/categorical/test_constructors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ def test_construction_with_ordered(self):
511511
cat = Categorical([0, 1, 2], ordered=True)
512512
assert cat.ordered
513513

514-
@pytest.mark.xfail(reason="Imaginary values not supported in Categorical")
514+
@pytest.mark.xfail(reason="Imaginary values not supported in Categorical",
515+
strict=True)
515516
def test_constructor_imaginary(self):
516517
values = [1, 2, 3 + 1j]
517518
c1 = Categorical(values)

pandas/tests/extension/base/setitem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ def test_setitem_frame_invalid_length(self, data):
159159
with tm.assert_raises_regex(ValueError, xpr):
160160
df['B'] = data[:5]
161161

162-
@pytest.mark.xfail(reason="GH-20441: setitem on extension types.")
162+
@pytest.mark.xfail(reason="GH#20441: setitem on extension types.",
163+
strict=True)
163164
def test_setitem_tuple_index(self, data):
164165
s = pd.Series(data[:2], index=[(0, 0), (0, 1)])
165166
expected = pd.Series(data.take([1, 1]), index=s.index)

pandas/tests/extension/integer/test_integer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,17 @@ def test_construct_cast_invalid(self, dtype):
599599

600600
class TestGroupby(BaseInteger, base.BaseGroupbyTests):
601601

602-
@pytest.mark.xfail(reason="groupby not working")
602+
@pytest.mark.xfail(reason="groupby not working", strict=True)
603603
def test_groupby_extension_no_sort(self, data_for_grouping):
604604
super(TestGroupby, self).test_groupby_extension_no_sort(
605605
data_for_grouping)
606606

607-
@pytest.mark.xfail(reason="groupby not working")
608-
@pytest.mark.parametrize('as_index', [True, False])
607+
@pytest.mark.parametrize('as_index', [
608+
pytest.param(True,
609+
marks=pytest.mark.xfail(reason="groupby not working",
610+
strict=True)),
611+
False
612+
])
609613
def test_groupby_extension_agg(self, as_index, data_for_grouping):
610614
super(TestGroupby, self).test_groupby_extension_agg(
611615
as_index, data_for_grouping)

pandas/tests/extension/json/test_json.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def test_custom_asserts(self):
142142

143143
class TestConstructors(BaseJSON, base.BaseConstructorsTests):
144144

145+
# TODO: Should this be pytest.mark.skip?
145146
@pytest.mark.xfail(reason="not implemented constructor from dtype")
146147
def test_from_dtype(self, data):
147148
# construct from our dtype & string dtype
@@ -157,10 +158,12 @@ class TestGetitem(BaseJSON, base.BaseGetitemTests):
157158

158159

159160
class TestMissing(BaseJSON, base.BaseMissingTests):
161+
# TODO: Should this be pytest.mark.skip?
160162
@pytest.mark.xfail(reason="Setting a dict as a scalar")
161163
def test_fillna_series(self):
162164
"""We treat dictionaries as a mapping in fillna, not a scalar."""
163165

166+
# TODO: Should this be pytest.mark.skip?
164167
@pytest.mark.xfail(reason="Setting a dict as a scalar")
165168
def test_fillna_frame(self):
166169
"""We treat dictionaries as a mapping in fillna, not a scalar."""
@@ -212,7 +215,7 @@ def test_combine_add(self, data_repeated):
212215

213216

214217
class TestCasting(BaseJSON, base.BaseCastingTests):
215-
218+
# TODO: Should this be pytest.mark.skip?
216219
@pytest.mark.xfail(reason="failing on np.array(self, dtype=str)")
217220
def test_astype_str(self):
218221
"""This currently fails in NumPy on np.array(self, dtype=str) with

pandas/tests/frame/test_arithmetic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def test_df_div_zero_series_does_not_commute(self):
201201

202202
class TestFrameArithmetic(object):
203203

204-
@pytest.mark.xfail(reason='GH#7996 datetime64 units not converted to nano')
204+
@pytest.mark.xfail(reason='GH#7996 datetime64 units not converted to nano',
205+
strict=True)
205206
def test_df_sub_datetime64_not_ns(self):
206207
df = pd.DataFrame(pd.date_range('20130101', periods=3))
207208
dt64 = np.datetime64('2013-01-01')

pandas/tests/frame/test_duplicates.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def test_duplicated_keep(keep, expected):
5555
tm.assert_series_equal(result, expected)
5656

5757

58-
@pytest.mark.xfail(reason="GH21720; nan/None falsely considered equal")
58+
@pytest.mark.xfail(reason="GH#21720; nan/None falsely considered equal",
59+
strict=True)
5960
@pytest.mark.parametrize('keep, expected', [
6061
('first', Series([False, False, True, False, True])),
6162
('last', Series([True, True, False, False, False])),

pandas/tests/groupby/aggregate/test_other.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,17 @@ def test_agg_structs_series(structure, expected):
487487
tm.assert_series_equal(result, expected)
488488

489489

490-
@pytest.mark.xfail(reason="GH-18869: agg func not called on empty groups.")
490+
@pytest.mark.parametrize('observed', [
491+
True,
492+
pytest.param(False,
493+
marks=pytest.mark.xfail(reason="GH#18869: agg func not "
494+
"called on empty groups.",
495+
strict=True)),
496+
pytest.param(None,
497+
marks=pytest.mark.xfail(reason="GH#18869: agg func not "
498+
"called on empty groups.",
499+
strict=True))
500+
])
491501
def test_agg_category_nansum(observed):
492502
categories = ['a', 'b', 'c']
493503
df = pd.DataFrame({"A": pd.Categorical(['a', 'a', 'b'],

pandas/tests/groupby/test_apply.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ def test_apply_trivial():
5858
tm.assert_frame_equal(result, expected)
5959

6060

61-
@pytest.mark.xfail(reason=("GH 20066; function passed into apply "
62-
"returns a DataFrame with the same index "
63-
"as the one to create GroupBy object."))
61+
@pytest.mark.xfail(reason="GH#20066; function passed into apply "
62+
"returns a DataFrame with the same index "
63+
"as the one to create GroupBy object.",
64+
strict=True)
6465
def test_apply_trivial_fail():
6566
# GH 20066
6667
# trivial apply fails if the constant dataframe has the same index

pandas/tests/indexes/interval/test_astype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_subtype_integer(self, subtype_start, subtype_end):
9595
closed=index.closed)
9696
tm.assert_index_equal(result, expected)
9797

98-
@pytest.mark.xfail(reason='GH 15832')
98+
@pytest.mark.xfail(reason='GH#15832', strict=True)
9999
def test_subtype_integer_errors(self):
100100
# int64 -> uint64 fails with negative values
101101
index = interval_range(-10, 10)
@@ -133,7 +133,7 @@ def test_subtype_integer(self, subtype):
133133
with tm.assert_raises_regex(ValueError, msg):
134134
index.insert(0, np.nan).astype(dtype)
135135

136-
@pytest.mark.xfail(reason='GH 15832')
136+
@pytest.mark.xfail(reason='GH#15832', strict=True)
137137
def test_subtype_integer_errors(self):
138138
# float64 -> uint64 fails with negative values
139139
index = interval_range(-10.0, 10.0)

pandas/tests/indexes/multi/test_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_nulls(idx):
8383
idx.isna()
8484

8585

86-
@pytest.mark.xfail
86+
@pytest.mark.xfail(strict=True)
8787
def test_hasnans_isnans(idx):
8888
# GH 11343, added tests for hasnans / isnans
8989
index = idx.copy()

0 commit comments

Comments
 (0)