From 90bad7b631e7d122b3a14fd2add1ff979e42ae6f Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 5 May 2021 20:12:15 -0700 Subject: [PATCH] TST: catch/suppress test warnings --- pandas/tests/generic/test_finalize.py | 5 ++++- pandas/tests/io/__init__.py | 6 ++++++ pandas/tests/io/formats/style/test_highlight.py | 5 ++++- pandas/tests/io/pytables/__init__.py | 3 +++ pandas/tests/io/pytables/test_categorical.py | 2 +- pandas/tests/io/test_parquet.py | 10 ++++++++-- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index dbe2df5238c7e..50ecb74924e2a 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -226,7 +226,10 @@ ), pytest.param( (pd.DataFrame, frame_mi_data, operator.methodcaller("count", level="A")), - marks=not_implemented_mark, + marks=[ + not_implemented_mark, + pytest.mark.filterwarnings("ignore:Using the level keyword:FutureWarning"), + ], ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("nunique")), diff --git a/pandas/tests/io/__init__.py b/pandas/tests/io/__init__.py index 39474dedba78c..3231e38b985af 100644 --- a/pandas/tests/io/__init__.py +++ b/pandas/tests/io/__init__.py @@ -5,6 +5,12 @@ pytest.mark.filterwarnings( "ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning" ), + pytest.mark.filterwarnings( + "ignore:Block.is_categorical is deprecated:DeprecationWarning" + ), + pytest.mark.filterwarnings( + r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning" + ), # xlrd pytest.mark.filterwarnings( "ignore:This method will be removed in future versions:DeprecationWarning" diff --git a/pandas/tests/io/formats/style/test_highlight.py b/pandas/tests/io/formats/style/test_highlight.py index 9e956e055d1aa..a681d7c65a190 100644 --- a/pandas/tests/io/formats/style/test_highlight.py +++ b/pandas/tests/io/formats/style/test_highlight.py @@ -5,6 +5,7 @@ DataFrame, IndexSlice, ) +import pandas._testing as tm pytest.importorskip("jinja2") @@ -54,7 +55,9 @@ def test_highlight_minmax_basic(df, f): } if f == "highlight_min": df = -df - result = getattr(df.style, f)(axis=1, color="red")._compute().ctx + with tm.assert_produces_warning(RuntimeWarning): + # All-NaN slice encountered + result = getattr(df.style, f)(axis=1, color="red")._compute().ctx assert result == expected diff --git a/pandas/tests/io/pytables/__init__.py b/pandas/tests/io/pytables/__init__.py index d3735f8863c3b..cbf848a401dc4 100644 --- a/pandas/tests/io/pytables/__init__.py +++ b/pandas/tests/io/pytables/__init__.py @@ -9,4 +9,7 @@ pytest.mark.filterwarnings( r"ignore:`np\.object` is a deprecated alias:DeprecationWarning" ), + pytest.mark.filterwarnings( + r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning" + ), ] diff --git a/pandas/tests/io/pytables/test_categorical.py b/pandas/tests/io/pytables/test_categorical.py index 4928a70f90960..0b3d56ebf959e 100644 --- a/pandas/tests/io/pytables/test_categorical.py +++ b/pandas/tests/io/pytables/test_categorical.py @@ -216,7 +216,7 @@ def test_convert_value(setup_path, where: str, df: DataFrame, expected: DataFram max_widths = {"col": 1} categorical_values = sorted(df.col.unique()) expected.col = expected.col.astype("category") - expected.col.cat.set_categories(categorical_values, inplace=True) + expected.col = expected.col.cat.set_categories(categorical_values) with ensure_clean_path(setup_path) as path: df.to_hdf(path, "df", format="table", min_itemsize=max_widths) diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 30666a716859a..f66451cd72309 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -3,7 +3,10 @@ from io import BytesIO import os import pathlib -from warnings import catch_warnings +from warnings import ( + catch_warnings, + filterwarnings, +) import numpy as np import pytest @@ -36,7 +39,10 @@ _HAVE_PYARROW = False try: - import fastparquet + with catch_warnings(): + # `np.bool` is a deprecated alias... + filterwarnings("ignore", "`np.bool`", category=DeprecationWarning) + import fastparquet _HAVE_FASTPARQUET = True except ImportError: