Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Clean up autouse fixtures #55269

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions pandas/tests/arithmetic/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,8 @@
RangeIndex,
)
import pandas._testing as tm
from pandas.core.computation import expressions as expr


@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
def switch_numexpr_min_elements(request):
_MIN_ELEMENTS = expr._MIN_ELEMENTS
expr._MIN_ELEMENTS = request.param
yield request.param
expr._MIN_ELEMENTS = _MIN_ELEMENTS


# ------------------------------------------------------------------


# doctest with +SKIP for one fixture fails during setup with
# 'DoctestItem' object has no attribute 'callspec'
# due to switch_numexpr_min_elements fixture
@pytest.fixture(params=[1, np.array(1, dtype=np.int64)])
def one(request):
"""
Expand Down Expand Up @@ -58,9 +43,6 @@ def one(request):
zeros.extend([0, 0.0, -0.0])


# doctest with +SKIP for zero fixture fails during setup with
# 'DoctestItem' object has no attribute 'callspec'
# due to switch_numexpr_min_elements fixture
@pytest.fixture(params=zeros)
def zero(request):
"""
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/arithmetic/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
)


@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
def switch_numexpr_min_elements(request, monkeypatch):
with monkeypatch.context() as m:
m.setattr(expr, "_MIN_ELEMENTS", request.param)
yield request.param


@pytest.fixture(params=[Index, Series, tm.to_array])
def box_pandas_1d_array(request):
"""
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@


@pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"])
def switch_numexpr_min_elements(request):
_MIN_ELEMENTS = expr._MIN_ELEMENTS
expr._MIN_ELEMENTS = request.param
yield request.param
expr._MIN_ELEMENTS = _MIN_ELEMENTS
def switch_numexpr_min_elements(request, monkeypatch):
with monkeypatch.context() as m:
m.setattr(expr, "_MIN_ELEMENTS", request.param)
yield request.param


class DummyElement:
Expand Down Expand Up @@ -1074,7 +1073,7 @@ def test_frame_with_frame_reindex(self):
],
ids=lambda x: x.__name__,
)
def test_binop_other(self, op, value, dtype, switch_numexpr_min_elements, request):
def test_binop_other(self, op, value, dtype, switch_numexpr_min_elements):
skip = {
(operator.truediv, "bool"),
(operator.pow, "bool"),
Expand Down
15 changes: 1 addition & 14 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import pytest
import pytz

from pandas._config import config

import pandas as pd
from pandas import (
DataFrame,
Expand Down Expand Up @@ -51,17 +49,6 @@ def get_local_am_pm():
return am_local, pm_local


@pytest.fixture(autouse=True)
def clean_config():
curr_deprecated_options = config._deprecated_options.copy()
curr_registered_options = config._registered_options.copy()
curr_global_config = config._global_config.copy()
yield
config._deprecated_options = curr_deprecated_options
config._registered_options = curr_registered_options
config._global_config = curr_global_config


@pytest.fixture(params=["string", "pathlike", "buffer"])
def filepath_or_buffer_id(request):
"""
Expand Down Expand Up @@ -3604,7 +3591,7 @@ def test_repr_html_ipython_config(ip):
df._repr_html_()
"""
)
result = ip.run_cell(code)
result = ip.run_cell(code, silent=True)
assert not result.error_in_exec


Expand Down
Loading