Skip to content

Commit 22818d9

Browse files
NIK-TIGER-BILLNIK-TIGER-BILLd-v-bmaxrjonespre-commit-ci[bot]
authored
fix(testing): correct delete_dir prefix matching in stateful tests (zarr-developers#4002)
* fix(testing): correct delete_dir prefix matching in stateful tests Fix flaky stateful test bookkeeping when delete_dir matches string prefixes instead of true directory descendants. A path such as 6/faNT... could be incorrectly removed when deleting 6/f. Closes zarr-developers#3977 Signed-off-by: NIK-TIGER-BILL <[email protected]> * fix: address review comment — remove standalone regression test per maintainer feedback Signed-off-by: NIK-TIGER-BILL <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: NIK-TIGER-BILL <[email protected]> Co-authored-by: NIK-TIGER-BILL <[email protected]> Co-authored-by: Davis Bennett <[email protected]> Co-authored-by: Max Jones <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a63ebd5 commit 22818d9

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎changes/3977.bugfix.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix flaky stateful test bookkeeping when `delete_dir` matches string prefixes instead of true directory descendants. Previously a path such as `6/faNT…` could be incorrectly removed when deleting `6/f`. (See [issue #3977](https://github.com/zarr-developers/zarr-python/issues/3977).)

‎src/zarr/testing/stateful.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def delete_dir(self, data: DataObject) -> None:
311311

312312
matches = set()
313313
for node in self.all_groups | self.all_arrays:
314-
if node.startswith(path):
314+
if node == path or node.startswith(path + "/"):
315315
matches.add(node)
316316
self.all_groups = self.all_groups - matches
317317
self.all_arrays = self.all_arrays - matches

0 commit comments

Comments
 (0)