|
| 1 | +# Stateful tests for arbitrary Zarr stores. |
| 2 | +import pytest |
| 3 | +from hypothesis.stateful import ( |
| 4 | + Settings, |
| 5 | + run_state_machine_as_test, |
| 6 | +) |
| 7 | + |
| 8 | +from zarr.abc.store import Store |
| 9 | +from zarr.storage import LocalStore, MemoryStore, ZipStore |
| 10 | +from zarr.testing.stateful import ZarrHierarchyStateMachine, ZarrStoreStateMachine |
| 11 | + |
| 12 | + |
| 13 | +def test_zarr_hierarchy(sync_store: Store): |
| 14 | + def mk_test_instance_sync() -> ZarrHierarchyStateMachine: |
| 15 | + return ZarrHierarchyStateMachine(sync_store) |
| 16 | + |
| 17 | + if isinstance(sync_store, ZipStore): |
| 18 | + 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) |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +def test_zarr_store(sync_store: Store) -> None: |
| 26 | + def mk_test_instance_sync() -> None: |
| 27 | + return ZarrStoreStateMachine(sync_store) |
| 28 | + |
| 29 | + if isinstance(sync_store, ZipStore): |
| 30 | + pytest.skip(reason="ZipStore does not support delete") |
| 31 | + if isinstance(sync_store, LocalStore): |
| 32 | + pytest.skip(reason="This test has errors") |
| 33 | + run_state_machine_as_test(mk_test_instance_sync, settings=Settings(report_multiple_bugs=True)) |
0 commit comments