diff --git a/conftest.py b/conftest.py index a8c16979e..9a44da193 100644 --- a/conftest.py +++ b/conftest.py @@ -18,11 +18,14 @@ from pathlib import Path -doctest_marker = pytest.mark.usefixtures("doctest_env") +@pytest.fixture(autouse=True) +def _suppress_env_for_doctests(request: pytest.FixtureRequest) -> None: + if not isinstance(request.node, pytest.DoctestItem): + request.getfixturevalue("_doctest_env") -@pytest.fixture -def doctest_env( +@pytest.fixture() +def _doctest_env( request: pytest.FixtureRequest, cache: pytest.Cache, tmp_path: Path ) -> Generator[None, None, None]: from scanpy import settings @@ -44,7 +47,7 @@ def doctest_env( def pytest_itemcollected(item: pytest.Item) -> None: - """Define behavior of pytest.mark.gpu and doctests.""" + """Define behavior of pytest.mark.gpu.""" from importlib.util import find_spec is_gpu = len([mark for mark in item.iter_markers(name="gpu")]) > 0 @@ -53,9 +56,6 @@ def pytest_itemcollected(item: pytest.Item) -> None: pytest.mark.skipif(not find_spec("cupy"), reason="Cupy not installed.") ) - if isinstance(item, pytest.DoctestItem): - item.add_marker(doctest_marker) - def pytest_addoption(parser: pytest.Parser) -> None: """Hook to register custom CLI options and config values""" diff --git a/pyproject.toml b/pyproject.toml index ffb275bde..3501d7667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ doc = [ ] test = [ "loompy>=3.0.5", - "pytest >=6.0, !=8.0.0rc1", # https://github.com/pytest-dev/pytest/issues/11759 + "pytest >=6.0", "pytest-cov>=2.10", "zarr", "matplotlib",