Skip to content

fix(testing): correct delete_dir prefix matching in stateful tests#4002

Open
NIK-TIGER-BILL wants to merge 1 commit into
zarr-developers:mainfrom
NIK-TIGER-BILL:fix-delete-dir-prefix-matching
Open

fix(testing): correct delete_dir prefix matching in stateful tests#4002
NIK-TIGER-BILL wants to merge 1 commit into
zarr-developers:mainfrom
NIK-TIGER-BILL:fix-delete-dir-prefix-matching

Conversation

@NIK-TIGER-BILL
Copy link
Copy Markdown
Contributor

This PR fixes a flaky bookkeeping bug in the Hypothesis stateful tests where delete_dir used raw string prefix matching (startswith) instead of true directory-descendant matching. A path such as 6/faNT7p7jvJsO3_C._HYi could be incorrectly removed from all_arrays/all_groups when deleting 6/f, because "6/faNT…".startswith("6/f") is True. The fix adds an explicit separator check: node == path or node.startswith(path + "/").

Closes #3977

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions (N/A – test-only change)
  • New/modified features documented in docs/user-guide/*.md (N/A – test-only change)
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

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 <nik.tiger.bill@github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.49%. Comparing base (c0e2afa) to head (d492d74).

Files with missing lines Patch % Lines
src/zarr/testing/stateful.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4002   +/-   ##
=======================================
  Coverage   93.49%   93.49%           
=======================================
  Files          88       88           
  Lines       11873    11873           
=======================================
  Hits        11101    11101           
  Misses        772      772           
Files with missing lines Coverage Δ
src/zarr/testing/stateful.py 36.46% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

run_state_machine_as_test(mk_test_instance_sync) # type: ignore[no-untyped-call]


def test_delete_dir_prefix_matching() -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's delete this; it's not neeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: delete_dir in stateful test uses raw startswith for bookkeeping, causing flaky KeyError in delete_group_using_del

2 participants