Skip to content

Commit f76c4c2

Browse files
authored
TST: stricter xfails, catch/suppress warnings (#33882)
1 parent 551c515 commit f76c4c2

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

pandas/tests/arithmetic/conftest.py

-16
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,6 @@ def box(request):
231231
return request.param
232232

233233

234-
@pytest.fixture(
235-
params=[
236-
pd.Index,
237-
pd.Series,
238-
pytest.param(pd.DataFrame, marks=pytest.mark.xfail),
239-
tm.to_array,
240-
],
241-
ids=id_func,
242-
)
243-
def box_df_fail(request):
244-
"""
245-
Fixture equivalent to `box` fixture but xfailing the DataFrame case.
246-
"""
247-
return request.param
248-
249-
250234
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame, tm.to_array], ids=id_func)
251235
def box_with_array(request):
252236
"""

pandas/tests/arithmetic/test_interval.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,15 @@ def test_compare_scalar_interval_mixed_closed(self, op, closed, other_closed):
126126
expected = self.elementwise_comparison(op, array, other)
127127
tm.assert_numpy_array_equal(result, expected)
128128

129-
def test_compare_scalar_na(self, op, array, nulls_fixture):
129+
def test_compare_scalar_na(self, op, array, nulls_fixture, request):
130130
result = op(array, nulls_fixture)
131131
expected = self.elementwise_comparison(op, array, nulls_fixture)
132132

133-
if nulls_fixture is pd.NA and array.dtype != pd.IntervalDtype("int"):
134-
pytest.xfail("broken for non-integer IntervalArray; see GH 31882")
133+
if nulls_fixture is pd.NA and array.dtype != pd.IntervalDtype("int64"):
134+
mark = pytest.mark.xfail(
135+
reason="broken for non-integer IntervalArray; see GH 31882"
136+
)
137+
request.node.add_marker(mark)
135138

136139
tm.assert_numpy_array_equal(result, expected)
137140

@@ -207,13 +210,15 @@ def test_compare_list_like_object(self, op, array, other):
207210
expected = self.elementwise_comparison(op, array, other)
208211
tm.assert_numpy_array_equal(result, expected)
209212

210-
def test_compare_list_like_nan(self, op, array, nulls_fixture):
213+
def test_compare_list_like_nan(self, op, array, nulls_fixture, request):
211214
other = [nulls_fixture] * 4
212215
result = op(array, other)
213216
expected = self.elementwise_comparison(op, array, other)
214217

215-
if nulls_fixture is pd.NA:
216-
pytest.xfail("broken for non-integer IntervalArray; see GH 31882")
218+
if nulls_fixture is pd.NA and array.dtype.subtype != "i8":
219+
reason = "broken for non-integer IntervalArray; see GH 31882"
220+
mark = pytest.mark.xfail(reason=reason)
221+
request.node.add_marker(mark)
217222

218223
tm.assert_numpy_array_equal(result, expected)
219224

pandas/tests/indexes/test_index_new.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_constructor_infer_periodindex(self):
8383
],
8484
)
8585
def test_constructor_infer_nat_dt_like(
86-
self, pos, klass, dtype, ctor, nulls_fixture
86+
self, pos, klass, dtype, ctor, nulls_fixture, request
8787
):
8888
expected = klass([NaT, NaT])
8989
assert expected.dtype == dtype
@@ -92,7 +92,8 @@ def test_constructor_infer_nat_dt_like(
9292

9393
if nulls_fixture is NA:
9494
expected = Index([NA, NaT])
95-
pytest.xfail("Broken with np.NaT ctor; see GH 31884")
95+
mark = pytest.mark.xfail(reason="Broken with np.NaT ctor; see GH 31884")
96+
request.node.add_marker(mark)
9697

9798
result = Index(data)
9899
tm.assert_index_equal(result, expected)

pandas/tests/io/test_common.py

+5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ def test_read_expands_user_home_dir(
235235
),
236236
],
237237
)
238+
@pytest.mark.filterwarnings(
239+
"ignore:This method will be removed in future versions. "
240+
r"Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead."
241+
":PendingDeprecationWarning"
242+
)
238243
def test_read_fspath_all(self, reader, module, path, datapath):
239244
pytest.importorskip(module)
240245
path = datapath(*path)

pandas/tests/plotting/test_datetimelike.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,9 @@ def test_add_matplotlib_datetime64(self):
14561456
# ax.xaxis.converter with a DatetimeConverter
14571457
s = Series(np.random.randn(10), index=date_range("1970-01-02", periods=10))
14581458
ax = s.plot()
1459-
ax.plot(s.index, s.values, color="g")
1459+
with tm.assert_produces_warning(DeprecationWarning):
1460+
# multi-dimensional indexing
1461+
ax.plot(s.index, s.values, color="g")
14601462
l1, l2 = ax.lines
14611463
tm.assert_numpy_array_equal(l1.get_xydata(), l2.get_xydata())
14621464

0 commit comments

Comments
 (0)