Skip to content

Commit

Permalink
Backport PR pandas-dev#57122 on branch 2.2.x (CI: autouse add_doctest…
Browse files Browse the repository at this point in the history
…_imports) (pandas-dev#57135)

Backport PR pandas-dev#57122: CI: autouse add_doctest_imports

Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and rhshadrach committed Jan 29, 2024
1 parent c1723cd commit 10b5873
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ def pytest_collection_modifyitems(items, config) -> None:

if is_doctest:
for item in items:
# autouse=True for the add_doctest_imports can lead to expensive teardowns
# since doctest_namespace is a session fixture
item.add_marker(pytest.mark.usefixtures("add_doctest_imports"))

for path, message in ignored_doctest_warnings:
ignore_doctest_warning(item, path, message)

Expand Down Expand Up @@ -250,7 +246,14 @@ def pytest_collection_modifyitems(items, config) -> None:
)


@pytest.fixture
# ----------------------------------------------------------------
# Autouse fixtures
# ----------------------------------------------------------------


# https://github.com/pytest-dev/pytest/issues/11873
# Would like to avoid autouse=True, but cannot as of pytest 8.0.0
@pytest.fixture(autouse=True)
def add_doctest_imports(doctest_namespace) -> None:
"""
Make `np` and `pd` names available for doctests.
Expand All @@ -259,9 +262,6 @@ def add_doctest_imports(doctest_namespace) -> None:
doctest_namespace["pd"] = pd


# ----------------------------------------------------------------
# Autouse fixtures
# ----------------------------------------------------------------
@pytest.fixture(autouse=True)
def configure_tests() -> None:
"""
Expand Down

0 comments on commit 10b5873

Please sign in to comment.