diff --git a/pandas/conftest.py b/pandas/conftest.py index e4e32ab4a7350..1a410f87c8552 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -92,10 +92,6 @@ except zoneinfo.ZoneInfoNotFoundError: # type: ignore[attr-defined] zoneinfo = None -# Until https://github.com/numpy/numpy/issues/19078 is sorted out, just suppress -suppress_npdev_promotion_warning = pytest.mark.filterwarnings( - "ignore:Promotion of numbers and bools:FutureWarning" -) # ---------------------------------------------------------------- # Configuration / Settings @@ -171,7 +167,6 @@ def pytest_collection_modifyitems(items, config) -> None: # mark all tests in the pandas/tests/frame directory with "arraymanager" if "/frame/" in item.nodeid: item.add_marker(pytest.mark.arraymanager) - item.add_marker(suppress_npdev_promotion_warning) for (mark, kwd, skip_if_found, arg_name) in marks: if kwd in item.keywords: diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index f9c6465cd948e..1ee74f62b6645 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -752,7 +752,9 @@ def get_median(x): return np.nan with warnings.catch_warnings(): # Suppress RuntimeWarning about All-NaN slice - warnings.filterwarnings("ignore", "All-NaN slice encountered") + warnings.filterwarnings( + "ignore", "All-NaN slice encountered", RuntimeWarning + ) res = np.nanmedian(x[mask]) return res @@ -780,7 +782,9 @@ def get_median(x): # fastpath for the skipna case with warnings.catch_warnings(): # Suppress RuntimeWarning about All-NaN slice - warnings.filterwarnings("ignore", "All-NaN slice encountered") + warnings.filterwarnings( + "ignore", "All-NaN slice encountered", RuntimeWarning + ) res = np.nanmedian(values, axis) else: diff --git a/pandas/tests/arrays/floating/test_function.py b/pandas/tests/arrays/floating/test_function.py index f31ac8f885de6..f2af3118c6cbe 100644 --- a/pandas/tests/arrays/floating/test_function.py +++ b/pandas/tests/arrays/floating/test_function.py @@ -9,7 +9,7 @@ @pytest.mark.parametrize("ufunc", [np.abs, np.sign]) # np.sign emits a warning with nans, -@pytest.mark.filterwarnings("ignore:invalid value encountered in sign") +@pytest.mark.filterwarnings("ignore:invalid value encountered in sign:RuntimeWarning") def test_ufuncs_single(ufunc): a = pd.array([1, 2, -3, np.nan], dtype="Float64") result = ufunc(a) diff --git a/pandas/tests/arrays/integer/test_function.py b/pandas/tests/arrays/integer/test_function.py index 000ed477666ea..e5177e9e50d71 100644 --- a/pandas/tests/arrays/integer/test_function.py +++ b/pandas/tests/arrays/integer/test_function.py @@ -8,7 +8,7 @@ @pytest.mark.parametrize("ufunc", [np.abs, np.sign]) # np.sign emits a warning with nans, -@pytest.mark.filterwarnings("ignore:invalid value encountered in sign") +@pytest.mark.filterwarnings("ignore:invalid value encountered in sign:RuntimeWarning") def test_ufuncs_single_int(ufunc): a = pd.array([1, 2, -3, np.nan]) result = ufunc(a) diff --git a/pandas/tests/io/excel/test_xlsxwriter.py b/pandas/tests/io/excel/test_xlsxwriter.py index 477d3b05c0a74..c4d02d71390cc 100644 --- a/pandas/tests/io/excel/test_xlsxwriter.py +++ b/pandas/tests/io/excel/test_xlsxwriter.py @@ -1,5 +1,4 @@ import contextlib -import warnings import pytest @@ -16,10 +15,7 @@ def test_column_format(ext): # Test that column formats are applied to cells. Test for issue #9167. # Applicable to xlsxwriter only. - with warnings.catch_warnings(): - # Ignore the openpyxl lxml warning. - warnings.simplefilter("ignore") - openpyxl = pytest.importorskip("openpyxl") + openpyxl = pytest.importorskip("openpyxl") with tm.ensure_clean(ext) as path: frame = DataFrame({"A": [123456, 123456], "B": [123456, 123456]}) diff --git a/pandas/tests/io/json/test_json_table_schema.py b/pandas/tests/io/json/test_json_table_schema.py index f4c8b9e764d6d..8cd5b8adb27a5 100644 --- a/pandas/tests/io/json/test_json_table_schema.py +++ b/pandas/tests/io/json/test_json_table_schema.py @@ -260,9 +260,6 @@ def test_read_json_from_to_json_results(self): tm.assert_frame_equal(result1, df) tm.assert_frame_equal(result2, df) - @pytest.mark.filterwarnings( - "ignore:an integer is required (got type float)*:DeprecationWarning" - ) def test_to_json(self, df_table): df = df_table df.index.name = "idx" @@ -439,9 +436,6 @@ def test_to_json_categorical_index(self): assert result == expected - @pytest.mark.filterwarnings( - "ignore:an integer is required (got type float)*:DeprecationWarning" - ) def test_date_format_raises(self, df_table): msg = ( "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): result = pd.read_json(out, orient="table") tm.assert_frame_equal(df, result) - @pytest.mark.filterwarnings( - "ignore:an integer is required (got type float)*:DeprecationWarning" - ) def test_comprehensive(self): df = DataFrame( { diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index d1de676a4eb2e..36a91d587a2ef 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -32,9 +32,6 @@ def assert_json_roundtrip_equal(result, expected, orient): tm.assert_frame_equal(result, expected) -@pytest.mark.filterwarnings( - "ignore:an integer is required (got type float)*:DeprecationWarning" -) class TestPandasContainer: @pytest.fixture def categorical_frame(self): diff --git a/pandas/tests/io/parser/common/test_read_errors.py b/pandas/tests/io/parser/common/test_read_errors.py index 798d64899a43c..845b6e373edd7 100644 --- a/pandas/tests/io/parser/common/test_read_errors.py +++ b/pandas/tests/io/parser/common/test_read_errors.py @@ -221,9 +221,9 @@ def test_open_file(request, all_parsers): file = Path(path) file.write_bytes(b"\xe4\na\n1") - # should not trigger a ResourceWarning - warnings.simplefilter("always", category=ResourceWarning) with warnings.catch_warnings(record=True) as record: + # should not trigger a ResourceWarning + warnings.simplefilter("always", category=ResourceWarning) with pytest.raises(csv.Error, match="Could not determine delimiter"): parser.read_csv(file, sep=None, encoding_errors="replace") assert len(record) == 0, record[0].message diff --git a/pandas/tests/io/pytables/test_append.py b/pandas/tests/io/pytables/test_append.py index 5633b9f8a71c7..80562e77cae02 100644 --- a/pandas/tests/io/pytables/test_append.py +++ b/pandas/tests/io/pytables/test_append.py @@ -26,7 +26,6 @@ pytestmark = pytest.mark.single_cpu -@pytest.mark.filterwarnings("ignore:object name:tables.exceptions.NaturalNameWarning") def test_append(setup_path): with ensure_clean_store(setup_path) as store: diff --git a/pandas/tests/io/pytables/test_retain_attributes.py b/pandas/tests/io/pytables/test_retain_attributes.py index 4a2bfee5dc2dc..3043cd3604e58 100644 --- a/pandas/tests/io/pytables/test_retain_attributes.py +++ b/pandas/tests/io/pytables/test_retain_attributes.py @@ -73,9 +73,6 @@ def test_retain_index_attributes(setup_path): store.append("df2", df3) -@pytest.mark.filterwarnings( - "ignore:\\nthe :pandas.io.pytables.AttributeConflictWarning" -) def test_retain_index_attributes2(tmp_path, setup_path): path = tmp_path / setup_path diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index cf83dfdad3f1f..06684f076aefe 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -31,9 +31,6 @@ ) _default_compressor = "blosc" -ignore_natural_naming_warning = pytest.mark.filterwarnings( - "ignore:object name:tables.exceptions.NaturalNameWarning" -) from pandas.io.pytables import ( HDFStore, @@ -154,7 +151,6 @@ def test_repr(setup_path): str(s) -@pytest.mark.filterwarnings("ignore:object name:tables.exceptions.NaturalNameWarning") def test_contains(setup_path): with ensure_clean_store(setup_path) as store: @@ -598,9 +594,6 @@ def test_overwrite_node(setup_path): tm.assert_series_equal(store["a"], ts) -@pytest.mark.filterwarnings( - "ignore:\\nthe :pandas.io.pytables.AttributeConflictWarning" -) def test_coordinates(setup_path): df = tm.makeTimeDataFrame() @@ -972,9 +965,6 @@ def test_columns_multiindex_modified(tmp_path, setup_path): assert cols2load_original == cols2load -pytest.mark.filterwarnings("ignore:object name:tables.exceptions.NaturalNameWarning") - - def test_to_hdf_with_object_column_names(tmp_path, setup_path): # GH9057 diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index f83b6b0373a87..06ab39b878e85 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -665,7 +665,12 @@ def psql_insert_copy(table, conn, keys, data_iter): def test_execute_typeerror(sqlite_iris_engine): with pytest.raises(TypeError, match="pandas.io.sql.execute requires a connection"): - sql.execute("select * from iris", sqlite_iris_engine) + with tm.assert_produces_warning( + FutureWarning, + match="`pandas.io.sql.execute` is deprecated and " + "will be removed in the future version.", + ): + sql.execute("select * from iris", sqlite_iris_engine) def test_execute_deprecated(sqlite_buildin_iris): diff --git a/pandas/tests/window/test_win_type.py b/pandas/tests/window/test_win_type.py index 71a7f8e76d058..8438e0727c174 100644 --- a/pandas/tests/window/test_win_type.py +++ b/pandas/tests/window/test_win_type.py @@ -110,7 +110,6 @@ def test_constructor_with_win_type_invalid(frame_or_series): @td.skip_if_no_scipy -@pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning") def test_window_with_args(step): # make sure that we are aggregating window functions correctly with arg r = Series(np.random.randn(100)).rolling(