Skip to content

Commit ba38d73

Browse files
authored
TST: suppress warnings we cant do anything about (#37522)
1 parent d4cd068 commit ba38d73

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

pandas/tests/io/excel/test_readers.py

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"xlrd",
2222
marks=[
2323
td.skip_if_no("xlrd"),
24-
pytest.mark.filterwarnings("ignore:.*(tree\\.iter|html argument)"),
2524
],
2625
),
2726
pytest.param(
@@ -35,7 +34,6 @@
3534
None,
3635
marks=[
3736
td.skip_if_no("xlrd"),
38-
pytest.mark.filterwarnings("ignore:.*(tree\\.iter|html argument)"),
3937
],
4038
),
4139
pytest.param("pyxlsb", marks=td.skip_if_no("pyxlsb")),

pandas/tests/io/pytables/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
pytestmark = [
4+
# pytables https://github.com/PyTables/PyTables/issues/822
5+
pytest.mark.filterwarnings(
6+
"ignore:a closed node found in the registry:UserWarning"
7+
),
8+
pytest.mark.filterwarnings(r"ignore:tostring\(\) is deprecated:DeprecationWarning"),
9+
]

pandas/util/_test_decorators.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_foo():
2727
from distutils.version import LooseVersion
2828
import locale
2929
from typing import Callable, Optional
30+
import warnings
3031

3132
import numpy as np
3233
import pytest
@@ -51,10 +52,20 @@ def safe_import(mod_name: str, min_version: Optional[str] = None):
5152
object
5253
The imported module if successful, or False
5354
"""
54-
try:
55-
mod = __import__(mod_name)
56-
except ImportError:
57-
return False
55+
with warnings.catch_warnings():
56+
# Suppress warnings that we can't do anything about,
57+
# e.g. from aiohttp
58+
warnings.filterwarnings(
59+
"ignore",
60+
category=DeprecationWarning,
61+
module="aiohttp",
62+
message=".*decorator is deprecated since Python 3.8.*",
63+
)
64+
65+
try:
66+
mod = __import__(mod_name)
67+
except ImportError:
68+
return False
5869

5970
if not min_version:
6071
return mod

0 commit comments

Comments
 (0)