Skip to content

Commit

Permalink
Attempt to fix issue with show_versions and pandas>=3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
loicdiridollou committed Aug 7, 2024
1 parent 7f35ae4 commit c0e6a1d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from contextlib import (
AbstractContextManager,
nullcontext,
)
from contextlib import nullcontext
import platform

import pandas as pd
Expand All @@ -17,17 +14,25 @@


def test_show_version():
with pytest_warns_bounded(
UserWarning,
match="Setuptools is replacing distutils",
upper="3.11.99",
version_str=platform.python_version(),
):
context: AbstractContextManager
if PD_LTE_22 and NUMPY20: # https://github.com/PyTables/PyTables/issues/1172
"""Test show_versions method types with split case for pandas and python versions."""
# https://github.com/PyTables/PyTables/issues/1172
context = nullcontext()
if PD_LTE_22:
# distutils warning is only raised with pandas<3.0.0
if NUMPY20:
context = pytest.raises(ValueError)
else:
context = nullcontext()
with (
pytest_warns_bounded(
UserWarning,
match="Setuptools is replacing distutils",
upper="3.11.99",
version_str=platform.python_version(),
),
context,
):
check(assert_type(pd.show_versions(True), None), type(None))
check(assert_type(pd.show_versions(False), None), type(None))
else:
with context:
check(assert_type(pd.show_versions(True), None), type(None))
check(assert_type(pd.show_versions(False), None), type(None))
Expand Down

0 comments on commit c0e6a1d

Please sign in to comment.