Skip to content

Commit ce814c2

Browse files
authored
TST: Clean up autouse fixtures (#55269)
* TST: Clean up autouse fixtures * Use another flavor_read_html
1 parent bdc2cd4 commit ce814c2

File tree

7 files changed

+313
-309
lines changed

7 files changed

+313
-309
lines changed

pandas/tests/arithmetic/conftest.py

-18
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,8 @@
77
RangeIndex,
88
)
99
import pandas._testing as tm
10-
from pandas.core.computation import expressions as expr
1110

1211

13-
@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
14-
def switch_numexpr_min_elements(request):
15-
_MIN_ELEMENTS = expr._MIN_ELEMENTS
16-
expr._MIN_ELEMENTS = request.param
17-
yield request.param
18-
expr._MIN_ELEMENTS = _MIN_ELEMENTS
19-
20-
21-
# ------------------------------------------------------------------
22-
23-
24-
# doctest with +SKIP for one fixture fails during setup with
25-
# 'DoctestItem' object has no attribute 'callspec'
26-
# due to switch_numexpr_min_elements fixture
2712
@pytest.fixture(params=[1, np.array(1, dtype=np.int64)])
2813
def one(request):
2914
"""
@@ -58,9 +43,6 @@ def one(request):
5843
zeros.extend([0, 0.0, -0.0])
5944

6045

61-
# doctest with +SKIP for zero fixture fails during setup with
62-
# 'DoctestItem' object has no attribute 'callspec'
63-
# due to switch_numexpr_min_elements fixture
6446
@pytest.fixture(params=zeros)
6547
def zero(request):
6648
"""

pandas/tests/arithmetic/test_numeric.py

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
)
3030

3131

32+
@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
33+
def switch_numexpr_min_elements(request, monkeypatch):
34+
with monkeypatch.context() as m:
35+
m.setattr(expr, "_MIN_ELEMENTS", request.param)
36+
yield request.param
37+
38+
3239
@pytest.fixture(params=[Index, Series, tm.to_array])
3340
def box_pandas_1d_array(request):
3441
"""

pandas/tests/frame/test_arithmetic.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333

3434

3535
@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
36-
def switch_numexpr_min_elements(request):
37-
_MIN_ELEMENTS = expr._MIN_ELEMENTS
38-
expr._MIN_ELEMENTS = request.param
39-
yield request.param
40-
expr._MIN_ELEMENTS = _MIN_ELEMENTS
36+
def switch_numexpr_min_elements(request, monkeypatch):
37+
with monkeypatch.context() as m:
38+
m.setattr(expr, "_MIN_ELEMENTS", request.param)
39+
yield request.param
4140

4241

4342
class DummyElement:
@@ -1074,7 +1073,7 @@ def test_frame_with_frame_reindex(self):
10741073
],
10751074
ids=lambda x: x.__name__,
10761075
)
1077-
def test_binop_other(self, op, value, dtype, switch_numexpr_min_elements, request):
1076+
def test_binop_other(self, op, value, dtype, switch_numexpr_min_elements):
10781077
skip = {
10791078
(operator.truediv, "bool"),
10801079
(operator.pow, "bool"),

pandas/tests/io/formats/test_format.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import pytest
2323
import pytz
2424

25-
from pandas._config import config
26-
2725
import pandas as pd
2826
from pandas import (
2927
DataFrame,
@@ -51,17 +49,6 @@ def get_local_am_pm():
5149
return am_local, pm_local
5250

5351

54-
@pytest.fixture(autouse=True)
55-
def clean_config():
56-
curr_deprecated_options = config._deprecated_options.copy()
57-
curr_registered_options = config._registered_options.copy()
58-
curr_global_config = config._global_config.copy()
59-
yield
60-
config._deprecated_options = curr_deprecated_options
61-
config._registered_options = curr_registered_options
62-
config._global_config = curr_global_config
63-
64-
6552
@pytest.fixture(params=["string", "pathlike", "buffer"])
6653
def filepath_or_buffer_id(request):
6754
"""
@@ -3604,7 +3591,7 @@ def test_repr_html_ipython_config(ip):
36043591
df._repr_html_()
36053592
"""
36063593
)
3607-
result = ip.run_cell(code)
3594+
result = ip.run_cell(code, silent=True)
36083595
assert not result.error_in_exec
36093596

36103597

0 commit comments

Comments
 (0)