Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move fixtures to tests #1813

Merged
merged 13 commits into from
Jul 21, 2024
Merged

Move fixtures to tests #1813

merged 13 commits into from
Jul 21, 2024

Conversation

d-v-b
Copy link
Contributor

@d-v-b d-v-b commented Apr 24, 2024

Move static fixtures from fixture to tests/fixture, and alter the corresponding tests to look for fixtures in the new location. These tests contained code for regenerating these fixtures if they were not found; I removed this code, because the fixtures are guaranteed to exist.

I think generating fixtures at testing time is better than using static files, but the changes here were easier to make. Down the road we can deprecate the static fixtures in a separate PR.

Also, this diff is extremely unwieldy because of the large number of objects in the fixtures directory. Do we really need thousands of files here? Here are the test files modified by this PR:

Addresses #1812

TODO:

  • Add unit tests and/or doctests in docstrings
  • [] Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@d-v-b d-v-b added the V3 Related to compatibility with V3 spec label Apr 24, 2024
@d-v-b
Copy link
Contributor Author

d-v-b commented Apr 24, 2024

note that tests are passing, but pre-commit and appveyor are not, presumably because there are too many files, leading to timeouts.

@d-v-b
Copy link
Contributor Author

d-v-b commented Jun 14, 2024

an alternative is to revisit #146 and make these arrays smaller

@d-v-b
Copy link
Contributor Author

d-v-b commented Jun 23, 2024

I think this is basically finished. A summary of the changes:

  • Since the static fixtures are only used by the v2 tests, I moved them all to tests/v2/fixture
  • There's a large number of static array fixtures that exist only to check that the array can be ready by a future version of zarr. This test is quetionably designed, because if the fixture files are not found, they are programmatically generated at test time, which undermines the premise of the test. Nonetheless, I kept these tests but reduced the number of chunks in each fixture array to 2, which keeps the number of checked in files low.
  • There are three tests that refer to static fixtures, but do not really need to -- one test checks whether a group can be created with the name "meta", and another test checks whether unicode strings can be written to attributes, and the last are checking dimension separator stuff. The first two now use the tmpdir fixture instead of static data, the latter uses static fixtures in the new tests/v2/fixture directory, but even that test could be done with a vanilla tmpdir fixture.

The diff is unreadable. I bundled the changes to the test code into a single commit to make this more reviewable. That's what reviewers should look at.

pre-commit is failing due to mypy issues, but I can't replicate that locally and it's not due to changes in this PR

@d-v-b d-v-b requested review from normanrz and jhamman June 23, 2024 21:20
@d-v-b
Copy link
Contributor Author

d-v-b commented Jul 19, 2024

In a separate effort, I just checked auto-generated fixture files into version control by mistake again 😮‍💨 can we get some eyes on this PR so we can fix this behavior.

@d-v-b d-v-b merged commit 48e2475 into zarr-developers:v3 Jul 21, 2024
24 checks passed
dcherian added a commit to dcherian/zarr-python that referenced this pull request Jul 25, 2024
* v3: (22 commits)
  chore: update pre-commit hooks (zarr-developers#2051)
  Apply ruff/flake8-bandit rule B006 (zarr-developers#2049)
  Move fixtures to `tests` (zarr-developers#1813)
  Multiple imports for an import name (zarr-developers#2047)
  Redundant list comprehension (zarr-developers#2048)
  chore: update pre-commit hooks (zarr-developers#2039)
  Cast fill value to array's dtype (zarr-developers#2020)
  chore: update pre-commit hooks (zarr-developers#2017)
  make shardingcodec pickleable  (zarr-developers#2011)
  doc: copy 3.0.0.alpha changelog into release.rst (zarr-developers#2007)
  build(ci): enable python 3.12 in github actions (zarr-developers#2005)
  Bump NumPy to 2.0 (zarr-developers#1983)
  chore: update pre-commit hooks (zarr-developers#1989)
  Fix indexing with bools (zarr-developers#1968)
  Fix string interpolation (zarr-developers#1998)
  Unnecessary comprehension (zarr-developers#1997)
  Stop ignoring these ruff rules (zarr-developers#2001)
  Merge collapsible if statements (zarr-developers#1999)
  Unnecessary comprehension (zarr-developers#1996)
  Handle Path in `make_store_path` (zarr-developers#1992)
  ...
d-v-b added a commit to d-v-b/zarr-python that referenced this pull request Jul 29, 2024
* fix: move test fixtures into tests/fixture

* fix: move test fixtures into tests/fixture

* use tmpdir instead of data fixture

* refactor fixture-depdendent tests

* refactor fixture-depdendent tests

* restore old tests, to try and make a clean commit, again

* checkout updated test routines

---------

Co-authored-by: Joe Hamman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V3 Related to compatibility with V3 spec
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants