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

+2-1
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

+2-1
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

+7-3
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

+4-1
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

+2-1
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

+2-1
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

+11-1
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

+4-3
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

+2-2
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

+1-1
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()

pandas/tests/indexes/period/test_arithmetic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ def test_pi_add_sub_td64_array_non_tick_raises(self):
356356
with pytest.raises(period.IncompatibleFrequency):
357357
tdarr - rng
358358

359-
@pytest.mark.xfail(reason='op with TimedeltaIndex raises, with ndarray OK')
359+
@pytest.mark.xfail(reason='op with TimedeltaIndex raises, with ndarray OK',
360+
strict=True)
360361
def test_pi_add_sub_td64_array_tick(self):
361362
rng = pd.period_range('1/1/2000', freq='Q', periods=3)
362363
dti = pd.date_range('2016-01-01', periods=3)

pandas/tests/indexes/test_base.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,9 @@ def test_constructor_overflow_int64(self):
491491
with tm.assert_raises_regex(OverflowError, msg):
492492
Index([np.iinfo(np.uint64).max - 1], dtype="int64")
493493

494-
@pytest.mark.xfail(reason="see gh-21311: Index "
495-
"doesn't enforce dtype argument")
494+
@pytest.mark.xfail(reason="see GH#21311: Index "
495+
"doesn't enforce dtype argument",
496+
strict=True)
496497
def test_constructor_cast(self):
497498
msg = "could not convert string to float"
498499
with tm.assert_raises_regex(ValueError, msg):
@@ -1455,7 +1456,8 @@ def test_slice_float_locs(self):
14551456
assert index2.slice_locs(8.5, 1.5) == (2, 6)
14561457
assert index2.slice_locs(10.5, -1) == (0, n)
14571458

1458-
@pytest.mark.xfail(reason="Assertions were not correct - see GH 20915")
1459+
@pytest.mark.xfail(reason="Assertions were not correct - see GH#20915",
1460+
strict=True)
14591461
def test_slice_ints_with_floats_raises(self):
14601462
# int slicing with floats
14611463
# GH 4892, these are all TypeErrors

pandas/tests/indexes/test_numeric.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def test_rpow_float(self):
150150
result = 2.0**idx
151151
tm.assert_index_equal(result, expected)
152152

153-
@pytest.mark.xfail(reason='GH#19252 Series has no __rdivmod__')
153+
@pytest.mark.xfail(reason='GH#19252 Series has no __rdivmod__',
154+
strict=True)
154155
def test_divmod_series(self):
155156
idx = self.create_index()
156157

pandas/tests/io/formats/test_to_csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def test_to_csv_string_array_ascii(self):
274274
with open(path, 'r') as f:
275275
assert f.read() == expected_ascii
276276

277-
@pytest.mark.xfail
277+
@pytest.mark.xfail(strict=True)
278278
def test_to_csv_string_array_utf8(self):
279279
# GH 10813
280280
str_array = [{'names': ['foo', 'bar']}, {'names': ['baz', 'qux']}]

pandas/tests/io/json/test_json_table_schema.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,10 @@ def test_mi_falsey_name(self):
495495
class TestTableOrientReader(object):
496496

497497
@pytest.mark.parametrize("index_nm", [
498-
None, "idx", pytest.param("index", marks=pytest.mark.xfail),
498+
None,
499+
"idx",
500+
pytest.param("index",
501+
marks=pytest.mark.xfail(strict=True)),
499502
'level_0'])
500503
@pytest.mark.parametrize("vals", [
501504
{'ints': [1, 2, 3, 4]},
@@ -504,7 +507,8 @@ class TestTableOrientReader(object):
504507
{'categoricals': pd.Series(pd.Categorical(['a', 'b', 'c', 'c']))},
505508
{'ordered_cats': pd.Series(pd.Categorical(['a', 'b', 'c', 'c'],
506509
ordered=True))},
507-
pytest.param({'floats': [1., 2., 3., 4.]}, marks=pytest.mark.xfail),
510+
pytest.param({'floats': [1., 2., 3., 4.]},
511+
marks=pytest.mark.xfail(strict=True)),
508512
{'floats': [1.1, 2.2, 3.3, 4.4]},
509513
{'bools': [True, False, False, True]}])
510514
def test_read_json_table_orient(self, index_nm, vals, recwarn):
@@ -562,7 +566,9 @@ def test_multiindex(self, index_names):
562566
tm.assert_frame_equal(df, result)
563567

564568
@pytest.mark.parametrize("strict_check", [
565-
pytest.param(True, marks=pytest.mark.xfail), False])
569+
pytest.param(True, marks=pytest.mark.xfail(strict=True)),
570+
False
571+
])
566572
def test_empty_frame_roundtrip(self, strict_check):
567573
# GH 21287
568574
df = pd.DataFrame([], columns=['a', 'b', 'c'])

pandas/tests/io/test_excel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,8 @@ def check_called(func):
22272227
pytest.param('xlwt',
22282228
marks=pytest.mark.xfail(reason='xlwt does not support '
22292229
'openpyxl-compatible '
2230-
'style dicts')),
2230+
'style dicts',
2231+
strict=True)),
22312232
'xlsxwriter',
22322233
'openpyxl',
22332234
])

pandas/tests/io/test_parquet.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ def test_options_get_engine(fp, pa):
216216

217217

218218
@pytest.mark.xfail(is_platform_windows() or is_platform_mac(),
219-
reason="reading pa metadata failing on Windows/mac")
219+
reason="reading pa metadata failing on Windows/mac",
220+
strict=True)
220221
def test_cross_engine_pa_fp(df_cross_compat, pa, fp):
221222
# cross-compat with differing reading/writing engines
222223

@@ -383,6 +384,7 @@ def test_basic(self, pa, df_full):
383384

384385
check_round_trip(df, pa)
385386

387+
# TODO: This doesn't fail on all systems; track down which
386388
@pytest.mark.xfail(reason="pyarrow fails on this (ARROW-1883)")
387389
def test_basic_subset_columns(self, pa, df_full):
388390
# GH18628

pandas/tests/plotting/test_frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ def test_subplots_timeseries_y_axis(self):
496496
testdata.plot(y="text")
497497

498498
@pytest.mark.xfail(reason='not support for period, categorical, '
499-
'datetime_mixed_tz')
499+
'datetime_mixed_tz',
500+
strict=True)
500501
def test_subplots_timeseries_y_axis_not_supported(self):
501502
"""
502503
This test will fail for:

pandas/tests/plotting/test_misc.py

-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def test_parallel_coordinates(self, iris):
212212
with tm.assert_produces_warning(FutureWarning):
213213
parallel_coordinates(df, 'Name', colors=colors)
214214

215-
@pytest.mark.xfail(reason="unreliable test")
216215
def test_parallel_coordinates_with_sorted_labels(self):
217216
""" For #15908 """
218217
from pandas.plotting import parallel_coordinates

pandas/tests/reshape/test_pivot.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ def test_pivot_with_list_like_values_nans(self, values):
458458
tm.assert_frame_equal(result, expected)
459459

460460
@pytest.mark.xfail(reason='MultiIndexed unstack with tuple names fails'
461-
'with KeyError #19966')
461+
'with KeyError GH#19966',
462+
strict=True)
462463
def test_pivot_with_multiindex(self):
463464
# issue #17160
464465
index = Index(data=[0, 1, 2, 3, 4, 5])
@@ -617,8 +618,9 @@ def test_margins_dtype(self):
617618

618619
tm.assert_frame_equal(expected, result)
619620

620-
@pytest.mark.xfail(reason='GH 17035 (len of floats is casted back to '
621-
'floats)')
621+
@pytest.mark.xfail(reason='GH#17035 (len of floats is casted back to '
622+
'floats)',
623+
strict=True)
622624
def test_margins_dtype_len(self):
623625
mi_val = list(product(['bar', 'foo'], ['one', 'two'])) + [('All', '')]
624626
mi = MultiIndex.from_tuples(mi_val, names=('A', 'B'))
@@ -1102,8 +1104,9 @@ def test_pivot_table_margins_name_with_aggfunc_list(self):
11021104
expected = pd.DataFrame(table.values, index=ix, columns=cols)
11031105
tm.assert_frame_equal(table, expected)
11041106

1105-
@pytest.mark.xfail(reason='GH 17035 (np.mean of ints is casted back to '
1106-
'ints)')
1107+
@pytest.mark.xfail(reason='GH#17035 (np.mean of ints is casted back to '
1108+
'ints)',
1109+
strict=True)
11071110
def test_categorical_margins(self, observed):
11081111
# GH 10989
11091112
df = pd.DataFrame({'x': np.arange(8),
@@ -1117,8 +1120,9 @@ def test_categorical_margins(self, observed):
11171120
table = df.pivot_table('x', 'y', 'z', dropna=observed, margins=True)
11181121
tm.assert_frame_equal(table, expected)
11191122

1120-
@pytest.mark.xfail(reason='GH 17035 (np.mean of ints is casted back to '
1121-
'ints)')
1123+
@pytest.mark.xfail(reason='GH#17035 (np.mean of ints is casted back to '
1124+
'ints)',
1125+
strict=True)
11221126
def test_categorical_margins_category(self, observed):
11231127
df = pd.DataFrame({'x': np.arange(8),
11241128
'y': np.arange(8) // 4,

pandas/tests/scalar/period/test_asfreq.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def test_asfreq_near_zero_weekly(self):
3232
assert week2.asfreq('D', 'S') <= per2
3333

3434
@pytest.mark.xfail(reason='GH#19643 period_helper asfreq functions fail '
35-
'to check for overflows')
35+
'to check for overflows',
36+
strict=True)
3637
def test_to_timestamp_out_of_bounds(self):
3738
# GH#19643, currently gives Timestamp('1754-08-30 22:43:41.128654848')
3839
per = Period('0001-01-01', freq='B')

pandas/tests/scalar/period/test_period.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,8 @@ def test_period_immutable():
14471447
per.freq = 2 * freq
14481448

14491449

1450-
@pytest.mark.xfail(reason='GH#19834 Period parsing error')
1450+
# TODO: This doesn't fail on all systems; track down which
1451+
@pytest.mark.xfail(reason="Parses as Jan 1, 0007 on some systems")
14511452
def test_small_year_parsing():
14521453
per1 = Period('0001-01-07', 'D')
14531454
assert per1.year == 1

pandas/tests/series/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,7 @@ def test_value_counts_with_nan(self):
20702070
"dtype",
20712071
["int_", "uint", "float_", "unicode_", "timedelta64[h]",
20722072
pytest.param("datetime64[D]",
2073-
marks=pytest.mark.xfail(reason="issue7996"))]
2073+
marks=pytest.mark.xfail(reason="GH#7996", strict=True))]
20742074
)
20752075
@pytest.mark.parametrize("is_ordered", [True, False])
20762076
def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):

pandas/tests/series/test_rank.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def test_rank_signature(self):
223223
'int64',
224224
marks=pytest.mark.xfail(
225225
reason="iNaT is equivalent to minimum value of dtype"
226-
"int64 pending issue #16674")),
226+
"int64 pending issue GH#16674",
227+
strict=True)),
227228
([NegInfinity(), '1', 'A', 'BA', 'Ba', 'C', Infinity()],
228229
'object')
229230
])

pandas/tests/sparse/frame/test_analytics.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from pandas.util import testing as tm
55

66

7-
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
8-
'(GH 17386)')
7+
@pytest.mark.xfail(reason='Wrong SparseBlock initialization (GH#17386)',
8+
strict=True)
99
def test_quantile():
1010
# GH 17386
1111
data = [[1, 1], [2, 10], [3, 100], [np.nan, np.nan]]
@@ -22,8 +22,8 @@ def test_quantile():
2222
tm.assert_sp_series_equal(result, sparse_expected)
2323

2424

25-
@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
26-
'(GH 17386)')
25+
@pytest.mark.xfail(reason='Wrong SparseBlock initialization (GH#17386)',
26+
strict=True)
2727
def test_quantile_multi():
2828
# GH 17386
2929
data = [[1, 1], [2, 10], [3, 100], [np.nan, np.nan]]

0 commit comments

Comments
 (0)