Skip to content

Conversation

@VeckoTheGecko
Copy link
Contributor

Fixes #1764

No more side effects from running the test suite 🎉

@VeckoTheGecko
Copy link
Contributor Author

VeckoTheGecko commented Nov 25, 2024

Not 100% sure if the time buffer is necessary. I get a "PermissionError" on a file one time but that was a once off.

Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Nice solution! Will this now also work on other files in the test_suite (e.g. test_particlfile.py, or many of the notebooks in docs/examples/*.ipynb that generate output zarr files)? Or does the fixture only work in the file (test_examples.py) in which it is created? Would be nice to have this for the entire test_suite?

@VeckoTheGecko
Copy link
Contributor Author

VeckoTheGecko commented Nov 25, 2024

The fixture is scoped to test_examples.py as it is unique to the test_example_script() function and how it invokes the scripts as these scripts aren't normal pytest tests. Normal Pytest tests should use the tmpdir fixture to handle cleanup.

Running pytest (no arguments - which runs the functions named test_* in tests and docs/examples as well as runs the __main__ scipts in docs/examples/example_*.py) now doesn't generate any loose data files.

Running the tutorial notebooks will still generate loose data files. I don't think its worth cleaning these up automatically as they're saved to docs/examples instead of the project root so are out of the way, and also the notebooks aren't normally run via pytest anyway. Devs can do find docs/examples -name '*.zarr' | xargs rm -r to remove this generated data.

Avoids modifying the scripts directly, meaning the scripts stay portable

xref #1764
@VeckoTheGecko VeckoTheGecko merged commit 3c94b3e into master Nov 25, 2024
14 checks passed
@VeckoTheGecko VeckoTheGecko deleted the v/1764 branch November 25, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Avoiding pytest suite side-effects (dataset saving)

3 participants