|
1 |
| -from contextlib import ( |
2 |
| - AbstractContextManager, |
3 |
| - nullcontext, |
4 |
| -) |
| 1 | +from contextlib import nullcontext |
5 | 2 | import platform
|
6 | 3 |
|
7 | 4 | import pandas as pd
|
|
17 | 14 |
|
18 | 15 |
|
19 | 16 | def test_show_version():
|
20 |
| - with pytest_warns_bounded( |
21 |
| - UserWarning, |
22 |
| - match="Setuptools is replacing distutils", |
23 |
| - upper="3.11.99", |
24 |
| - version_str=platform.python_version(), |
25 |
| - ): |
26 |
| - context: AbstractContextManager |
27 |
| - if PD_LTE_22 and NUMPY20: # https://github.com/PyTables/PyTables/issues/1172 |
| 17 | + """Test show_versions method types with split case for pandas and python versions.""" |
| 18 | + # https://github.com/PyTables/PyTables/issues/1172 |
| 19 | + context = nullcontext() |
| 20 | + if PD_LTE_22: |
| 21 | + # distutils warning is only raised with pandas<3.0.0 |
| 22 | + if NUMPY20: |
28 | 23 | context = pytest.raises(ValueError)
|
29 |
| - else: |
30 |
| - context = nullcontext() |
| 24 | + with ( |
| 25 | + pytest_warns_bounded( |
| 26 | + UserWarning, |
| 27 | + match="Setuptools is replacing distutils", |
| 28 | + upper="3.11.99", |
| 29 | + version_str=platform.python_version(), |
| 30 | + ), |
| 31 | + context, |
| 32 | + ): |
| 33 | + check(assert_type(pd.show_versions(True), None), type(None)) |
| 34 | + check(assert_type(pd.show_versions(False), None), type(None)) |
| 35 | + else: |
31 | 36 | with context:
|
32 | 37 | check(assert_type(pd.show_versions(True), None), type(None))
|
33 | 38 | check(assert_type(pd.show_versions(False), None), type(None))
|
|
0 commit comments