From ab35693d32ef776f22e01068841d39afd16d523f Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 16 Jul 2025 11:35:05 -0700 Subject: [PATCH 1/3] Provide pytest-plugin that registers a 'gpu' marker. https://github.com/zarr-developers/zarr-python/pull/3191/files#diff-a801b931f5dd8cd7df666e3f9936ff520669296303d3a3e469514443211885bdR43 changed `zarr.testing.utils` to use a top-level `pytest.mark.gpu`. Many projects, including zarr, run with `--strict-markers` which causes pytest to raise an error if the test you're running uses an unregistered marker. This didn't cause any issues for zarr, since we already registered the `gpu` marker. However, downstream projects are intended to run the `StoreTests`, which exposes them to this marker. To ensure they get it when installing zarr, we'll include an entrypoint with pytest, so that pytest calls our code to register this marker when these tests run. --- changes/+c563f4d4.bugfix.rst | 1 + pyproject.toml | 3 +++ src/zarr/testing/conftest.py | 9 +++++++++ 3 files changed, 13 insertions(+) create mode 100644 changes/+c563f4d4.bugfix.rst create mode 100644 src/zarr/testing/conftest.py diff --git a/changes/+c563f4d4.bugfix.rst b/changes/+c563f4d4.bugfix.rst new file mode 100644 index 0000000000..6f9fedaa46 --- /dev/null +++ b/changes/+c563f4d4.bugfix.rst @@ -0,0 +1 @@ +Register 'gpu' marker with pytest for downstream StoreTests. diff --git a/pyproject.toml b/pyproject.toml index 85517d8d0a..8accc49120 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -455,3 +455,6 @@ issue_format = ":issue:`{issue}`" [tool.codespell] ignore-words-list = "astroid" + +[project.entry-points.pytest11] +zarr = "zarr.testing" diff --git a/src/zarr/testing/conftest.py b/src/zarr/testing/conftest.py new file mode 100644 index 0000000000..59c148e0ec --- /dev/null +++ b/src/zarr/testing/conftest.py @@ -0,0 +1,9 @@ +import pytest + + +def pytest_configure(config: pytest.Config) -> None: + # The tests in zarr.testing are intended to be run by downstream projects. + # To allow those downstream projects to run with `--strict-markers`, we need + # to register an entry point with pytest11 and register our "plugin" with it, + # which just registers the markers used in zarr.testing + config.addinivalue_line("markers", "gpu: mark a test as requiring CuPy and GPU") From fefb844e3285761b32f6c1a8e404bc1485f14509 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 16 Jul 2025 11:53:20 -0700 Subject: [PATCH 2/3] coverage -- ignore --- src/zarr/testing/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zarr/testing/conftest.py b/src/zarr/testing/conftest.py index 59c148e0ec..9d53b051d9 100644 --- a/src/zarr/testing/conftest.py +++ b/src/zarr/testing/conftest.py @@ -1,7 +1,7 @@ import pytest -def pytest_configure(config: pytest.Config) -> None: +def pytest_configure(config: pytest.Config) -> None: # pragma: no cover # The tests in zarr.testing are intended to be run by downstream projects. # To allow those downstream projects to run with `--strict-markers`, we need # to register an entry point with pytest11 and register our "plugin" with it, From 13bcf1b14d81f8a191835d18d399b0ced1bd4321 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 16 Jul 2025 12:09:45 -0700 Subject: [PATCH 3/3] Fixed coverage for real --- pyproject.toml | 1 + src/zarr/testing/conftest.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8accc49120..102ee76df6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,6 +138,7 @@ exclude_lines = [ [tool.coverage.run] omit = [ "bench/compress_normal.py", + "src/zarr/testing/conftest.py", # only for downstream projects ] [tool.hatch] diff --git a/src/zarr/testing/conftest.py b/src/zarr/testing/conftest.py index 9d53b051d9..59c148e0ec 100644 --- a/src/zarr/testing/conftest.py +++ b/src/zarr/testing/conftest.py @@ -1,7 +1,7 @@ import pytest -def pytest_configure(config: pytest.Config) -> None: # pragma: no cover +def pytest_configure(config: pytest.Config) -> None: # The tests in zarr.testing are intended to be run by downstream projects. # To allow those downstream projects to run with `--strict-markers`, we need # to register an entry point with pytest11 and register our "plugin" with it,