Skip to content

Commit

Permalink
Fix test compatibility with Pytest 8
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jan 12, 2024
1 parent 4a1caa9 commit 89edefd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 89edefd

Please sign in to comment.