Skip to content

Commit 9ae874c

Browse files
Provide pytest-plugin that registers a 'gpu' marker. (#3258)
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.
1 parent 9969a5d commit 9ae874c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

changes/+c563f4d4.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Register 'gpu' marker with pytest for downstream StoreTests.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ exclude_lines = [
138138
[tool.coverage.run]
139139
omit = [
140140
"bench/compress_normal.py",
141+
"src/zarr/testing/conftest.py", # only for downstream projects
141142
]
142143

143144
[tool.hatch]
@@ -455,3 +456,6 @@ issue_format = ":issue:`{issue}`"
455456

456457
[tool.codespell]
457458
ignore-words-list = "astroid"
459+
460+
[project.entry-points.pytest11]
461+
zarr = "zarr.testing"

src/zarr/testing/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
4+
def pytest_configure(config: pytest.Config) -> None:
5+
# The tests in zarr.testing are intended to be run by downstream projects.
6+
# To allow those downstream projects to run with `--strict-markers`, we need
7+
# to register an entry point with pytest11 and register our "plugin" with it,
8+
# which just registers the markers used in zarr.testing
9+
config.addinivalue_line("markers", "gpu: mark a test as requiring CuPy and GPU")

0 commit comments

Comments
 (0)