Skip to content

Commit d740c7a

Browse files
committed
Restrict stateful tests to slow hypothesis CI workflow.
1 parent a52048d commit d740c7a

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ run = "run-coverage --no-cov"
161161
run-pytest = "run"
162162
run-verbose = "run-coverage --verbose"
163163
run-mypy = "mypy src"
164-
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
164+
run-hypothesis = "pytest --hypothesis-profile ci --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*"
165165
list-env = "pip list"
166166

167167
[tool.hatch.envs.doctest]
@@ -398,7 +398,8 @@ filterwarnings = [
398398
"ignore:.*is currently not part in the Zarr format 3 specification.*:UserWarning",
399399
]
400400
markers = [
401-
"gpu: mark a test as requiring CuPy and GPU"
401+
"gpu: mark a test as requiring CuPy and GPU",
402+
"slow_hypothesis: slow hypothesis tests",
402403
]
403404

404405
[tool.repo-review]

src/zarr/testing/stateful.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
MAX_BINARY_SIZE = 100
2727

28+
# Handle possible case-insensitive file systems (e.g. MacOS)
29+
node_names = node_names.map(lambda x: x.lower())
30+
2831

2932
def split_prefix_name(path: str) -> tuple[str, str]:
3033
split = path.rsplit("/", maxsplit=1)

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ def zarr_format(request: pytest.FixtureRequest) -> ZarrFormat:
147147
raise ValueError(msg)
148148

149149

150+
def pytest_addoption(parser: Any) -> None:
151+
parser.addoption(
152+
"--run-slow-hypothesis",
153+
action="store_true",
154+
default=False,
155+
help="run slow hypothesis tests",
156+
)
157+
158+
159+
def pytest_collection_modifyitems(config: Any, items: Any) -> None:
160+
if config.getoption("--run-slow-hypothesis"):
161+
return
162+
skip_slow_hyp = pytest.mark.skip(reason="need --run-slow-hypothesis option to run")
163+
for item in items:
164+
if "slow_hypothesis" in item.keywords:
165+
item.add_marker(skip_slow_hyp)
166+
167+
150168
settings.register_profile(
151169
"ci",
152170
max_examples=1000,

tests/test_store/test_stateful.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
# Stateful tests for arbitrary Zarr stores.
22
import pytest
33
from hypothesis.stateful import (
4-
Settings,
54
run_state_machine_as_test,
65
)
76

87
from zarr.abc.store import Store
9-
from zarr.storage import LocalStore, MemoryStore, ZipStore
8+
from zarr.storage import ZipStore
109
from zarr.testing.stateful import ZarrHierarchyStateMachine, ZarrStoreStateMachine
1110

11+
pytestmark = pytest.mark.slow_hypothesis
12+
1213

1314
def test_zarr_hierarchy(sync_store: Store):
1415
def mk_test_instance_sync() -> ZarrHierarchyStateMachine:
1516
return ZarrHierarchyStateMachine(sync_store)
1617

1718
if isinstance(sync_store, ZipStore):
1819
pytest.skip(reason="ZipStore does not support delete")
19-
if isinstance(sync_store, MemoryStore):
20-
run_state_machine_as_test(
21-
mk_test_instance_sync, settings=Settings(report_multiple_bugs=False, max_examples=50)
22-
)
20+
21+
run_state_machine_as_test(mk_test_instance_sync)
2322

2423

2524
def test_zarr_store(sync_store: Store) -> None:
@@ -28,11 +27,5 @@ def mk_test_instance_sync() -> None:
2827

2928
if isinstance(sync_store, ZipStore):
3029
pytest.skip(reason="ZipStore does not support delete")
31-
elif isinstance(sync_store, LocalStore):
32-
pytest.skip(reason="This test has errors")
33-
elif isinstance(sync_store, MemoryStore):
34-
run_state_machine_as_test(mk_test_instance_sync, settings=Settings(max_examples=50))
35-
else:
36-
run_state_machine_as_test(
37-
mk_test_instance_sync, settings=Settings(report_multiple_bugs=True)
38-
)
30+
31+
run_state_machine_as_test(mk_test_instance_sync)

0 commit comments

Comments
 (0)