Skip to content

Commit 7f57526

Browse files
jbrockmendelJulianWgs
authored andcommitted
TST: catch/suppress test warnings (pandas-dev#41346)
1 parent 18f3fd5 commit 7f57526

File tree

6 files changed

+26
-5
lines changed

6 files changed

+26
-5
lines changed

pandas/tests/generic/test_finalize.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@
226226
),
227227
pytest.param(
228228
(pd.DataFrame, frame_mi_data, operator.methodcaller("count", level="A")),
229-
marks=not_implemented_mark,
229+
marks=[
230+
not_implemented_mark,
231+
pytest.mark.filterwarnings("ignore:Using the level keyword:FutureWarning"),
232+
],
230233
),
231234
pytest.param(
232235
(pd.DataFrame, frame_data, operator.methodcaller("nunique")),

pandas/tests/io/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
pytest.mark.filterwarnings(
66
"ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning"
77
),
8+
pytest.mark.filterwarnings(
9+
"ignore:Block.is_categorical is deprecated:DeprecationWarning"
10+
),
11+
pytest.mark.filterwarnings(
12+
r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning"
13+
),
814
# xlrd
915
pytest.mark.filterwarnings(
1016
"ignore:This method will be removed in future versions:DeprecationWarning"

pandas/tests/io/formats/style/test_highlight.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
DataFrame,
66
IndexSlice,
77
)
8+
import pandas._testing as tm
89

910
pytest.importorskip("jinja2")
1011

@@ -54,7 +55,9 @@ def test_highlight_minmax_basic(df, f):
5455
}
5556
if f == "highlight_min":
5657
df = -df
57-
result = getattr(df.style, f)(axis=1, color="red")._compute().ctx
58+
with tm.assert_produces_warning(RuntimeWarning):
59+
# All-NaN slice encountered
60+
result = getattr(df.style, f)(axis=1, color="red")._compute().ctx
5861
assert result == expected
5962

6063

pandas/tests/io/pytables/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
pytest.mark.filterwarnings(
1010
r"ignore:`np\.object` is a deprecated alias:DeprecationWarning"
1111
),
12+
pytest.mark.filterwarnings(
13+
r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning"
14+
),
1215
]

pandas/tests/io/pytables/test_categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_convert_value(setup_path, where: str, df: DataFrame, expected: DataFram
216216
max_widths = {"col": 1}
217217
categorical_values = sorted(df.col.unique())
218218
expected.col = expected.col.astype("category")
219-
expected.col.cat.set_categories(categorical_values, inplace=True)
219+
expected.col = expected.col.cat.set_categories(categorical_values)
220220

221221
with ensure_clean_path(setup_path) as path:
222222
df.to_hdf(path, "df", format="table", min_itemsize=max_widths)

pandas/tests/io/test_parquet.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from io import BytesIO
44
import os
55
import pathlib
6-
from warnings import catch_warnings
6+
from warnings import (
7+
catch_warnings,
8+
filterwarnings,
9+
)
710

811
import numpy as np
912
import pytest
@@ -36,7 +39,10 @@
3639
_HAVE_PYARROW = False
3740

3841
try:
39-
import fastparquet
42+
with catch_warnings():
43+
# `np.bool` is a deprecated alias...
44+
filterwarnings("ignore", "`np.bool`", category=DeprecationWarning)
45+
import fastparquet
4046

4147
_HAVE_FASTPARQUET = True
4248
except ImportError:

0 commit comments

Comments
 (0)