Skip to content

Commit b173e7b

Browse files
authored
TST: Cleanup more warning filtering (#50723)
* TST: Cleanup more warning filtering * Catch another futurewarning
1 parent 2c994c7 commit b173e7b

File tree

13 files changed

+17
-44
lines changed

13 files changed

+17
-44
lines changed

pandas/conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@
9292
except zoneinfo.ZoneInfoNotFoundError: # type: ignore[attr-defined]
9393
zoneinfo = None
9494

95-
# Until https://github.com/numpy/numpy/issues/19078 is sorted out, just suppress
96-
suppress_npdev_promotion_warning = pytest.mark.filterwarnings(
97-
"ignore:Promotion of numbers and bools:FutureWarning"
98-
)
9995

10096
# ----------------------------------------------------------------
10197
# Configuration / Settings
@@ -171,7 +167,6 @@ def pytest_collection_modifyitems(items, config) -> None:
171167
# mark all tests in the pandas/tests/frame directory with "arraymanager"
172168
if "/frame/" in item.nodeid:
173169
item.add_marker(pytest.mark.arraymanager)
174-
item.add_marker(suppress_npdev_promotion_warning)
175170

176171
for (mark, kwd, skip_if_found, arg_name) in marks:
177172
if kwd in item.keywords:

pandas/core/nanops.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,9 @@ def get_median(x):
752752
return np.nan
753753
with warnings.catch_warnings():
754754
# Suppress RuntimeWarning about All-NaN slice
755-
warnings.filterwarnings("ignore", "All-NaN slice encountered")
755+
warnings.filterwarnings(
756+
"ignore", "All-NaN slice encountered", RuntimeWarning
757+
)
756758
res = np.nanmedian(x[mask])
757759
return res
758760

@@ -780,7 +782,9 @@ def get_median(x):
780782
# fastpath for the skipna case
781783
with warnings.catch_warnings():
782784
# Suppress RuntimeWarning about All-NaN slice
783-
warnings.filterwarnings("ignore", "All-NaN slice encountered")
785+
warnings.filterwarnings(
786+
"ignore", "All-NaN slice encountered", RuntimeWarning
787+
)
784788
res = np.nanmedian(values, axis)
785789

786790
else:

pandas/tests/arrays/floating/test_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@pytest.mark.parametrize("ufunc", [np.abs, np.sign])
1111
# np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127>
12-
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign")
12+
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign:RuntimeWarning")
1313
def test_ufuncs_single(ufunc):
1414
a = pd.array([1, 2, -3, np.nan], dtype="Float64")
1515
result = ufunc(a)

pandas/tests/arrays/integer/test_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@pytest.mark.parametrize("ufunc", [np.abs, np.sign])
1010
# np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127>
11-
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign")
11+
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign:RuntimeWarning")
1212
def test_ufuncs_single_int(ufunc):
1313
a = pd.array([1, 2, -3, np.nan])
1414
result = ufunc(a)

pandas/tests/io/excel/test_xlsxwriter.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import contextlib
2-
import warnings
32

43
import pytest
54

@@ -16,10 +15,7 @@
1615
def test_column_format(ext):
1716
# Test that column formats are applied to cells. Test for issue #9167.
1817
# Applicable to xlsxwriter only.
19-
with warnings.catch_warnings():
20-
# Ignore the openpyxl lxml warning.
21-
warnings.simplefilter("ignore")
22-
openpyxl = pytest.importorskip("openpyxl")
18+
openpyxl = pytest.importorskip("openpyxl")
2319

2420
with tm.ensure_clean(ext) as path:
2521
frame = DataFrame({"A": [123456, 123456], "B": [123456, 123456]})

pandas/tests/io/json/test_json_table_schema.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@ def test_read_json_from_to_json_results(self):
260260
tm.assert_frame_equal(result1, df)
261261
tm.assert_frame_equal(result2, df)
262262

263-
@pytest.mark.filterwarnings(
264-
"ignore:an integer is required (got type float)*:DeprecationWarning"
265-
)
266263
def test_to_json(self, df_table):
267264
df = df_table
268265
df.index.name = "idx"
@@ -439,9 +436,6 @@ def test_to_json_categorical_index(self):
439436

440437
assert result == expected
441438

442-
@pytest.mark.filterwarnings(
443-
"ignore:an integer is required (got type float)*:DeprecationWarning"
444-
)
445439
def test_date_format_raises(self, df_table):
446440
msg = (
447441
"Trying to write with `orient='table'` and `date_format='epoch'`. Table "
@@ -785,9 +779,6 @@ def test_read_json_table_timezones_orient(self, idx, vals, recwarn):
785779
result = pd.read_json(out, orient="table")
786780
tm.assert_frame_equal(df, result)
787781

788-
@pytest.mark.filterwarnings(
789-
"ignore:an integer is required (got type float)*:DeprecationWarning"
790-
)
791782
def test_comprehensive(self):
792783
df = DataFrame(
793784
{

pandas/tests/io/json/test_pandas.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def assert_json_roundtrip_equal(result, expected, orient):
3232
tm.assert_frame_equal(result, expected)
3333

3434

35-
@pytest.mark.filterwarnings(
36-
"ignore:an integer is required (got type float)*:DeprecationWarning"
37-
)
3835
class TestPandasContainer:
3936
@pytest.fixture
4037
def categorical_frame(self):

pandas/tests/io/parser/common/test_read_errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ def test_open_file(request, all_parsers):
221221
file = Path(path)
222222
file.write_bytes(b"\xe4\na\n1")
223223

224-
# should not trigger a ResourceWarning
225-
warnings.simplefilter("always", category=ResourceWarning)
226224
with warnings.catch_warnings(record=True) as record:
225+
# should not trigger a ResourceWarning
226+
warnings.simplefilter("always", category=ResourceWarning)
227227
with pytest.raises(csv.Error, match="Could not determine delimiter"):
228228
parser.read_csv(file, sep=None, encoding_errors="replace")
229229
assert len(record) == 0, record[0].message

pandas/tests/io/pytables/test_append.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
pytestmark = pytest.mark.single_cpu
2727

2828

29-
@pytest.mark.filterwarnings("ignore:object name:tables.exceptions.NaturalNameWarning")
3029
def test_append(setup_path):
3130

3231
with ensure_clean_store(setup_path) as store:

pandas/tests/io/pytables/test_retain_attributes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ def test_retain_index_attributes(setup_path):
7373
store.append("df2", df3)
7474

7575

76-
@pytest.mark.filterwarnings(
77-
"ignore:\\nthe :pandas.io.pytables.AttributeConflictWarning"
78-
)
7976
def test_retain_index_attributes2(tmp_path, setup_path):
8077
path = tmp_path / setup_path
8178

0 commit comments

Comments
 (0)