test: write test output to tmp_path, untrack generated FITS artifacts - #495
Merged
Merged
Conversation
test_autoarray wrote test *output* into tracked paths, so any change to the autonerves FITS writer rewrote a committed binary and dirtied the tree for every contributor. #483 demonstrated it: the PyAutoNerves#155 header-comment fix ([""] -> "") silently modified structures/arrays/files/array/output_test/array.fits the moment the autonerves floor moved -- identical cards, values, data and byte size, but a modified tracked file that had to be committed into an unrelated PR. Applies the durable fix uniformly rather than patching file-by-file again: the nine tests that wrote into an output_test/ directory now take pytest's tmp_path and drop their rmtree/makedirs preamble. After a full run no output_test/ directory is created anywhere in the source tree. Untracks the 13 exposed artifacts. Only one of them was a live output -- the array.fits that #483 flipped. The other twelve were orphans: no test referenced their paths, and a repo-wide grep for their basenames returned nothing. They were residue from tests deleted long ago, as were the two file-by-file .gitignore lines, now replaced by a test_autoarray/**/output_test/ pattern that serves as a backstop against a future writer regressing this. Two incidental fixes fall out. test_uniform_1d and test_uniform_2d both rmtree'd the same shared output directory, an ordering hazard tmp_path removes. And the three imaging tests that took the test_data_path fixture wrote their generated FITS into the source tree via that fixture; they now use tmp_path and the fixture is gone. Verified from a clean checkout: 1177 passed, 55 skipped, run twice in a row with git status clean after each -- the second run is what would catch a test that had silently depended on a committed artifact. Closes #494 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QoAeGsJyiaLG4oqXb9n3dM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_autoarraywrote test output into tracked paths, so any change to the autonervesFITS writer rewrote a committed binary and dirtied the tree for every contributor. #483
demonstrated it: the PyAutoNerves#155 header-comment fix (
[""]->"") silently modifiedstructures/arrays/files/array/output_test/array.fitsthe moment the autonerves floor moved —identical cards, values, data and byte size, but a modified tracked file that had to be either
committed into an unrelated PR or left dirtying the tree.
This applies the durable fix uniformly rather than patching file-by-file again. The nine tests
that wrote into an
output_test/directory now take pytest'stmp_pathand drop theirrmtree/makedirspreamble, and the 13 exposed artifacts are untracked. After a full run nooutput_test/directory is created anywhere in the source tree.The scope narrowed after auditing the inventory
Of the 13 tracked files, only one was a live output — the
array.fitsthat #483 flipped. Theother 12 were orphans: no test referenced their paths, and a repo-wide grep for their basenames
returned nothing. They were residue from tests deleted long ago — as were the two file-by-file
.gitignorelines, which named generated files for a test that no longer exists.The issue's open question about
test_uniform_1d.py:12resolves the same way: that path waswritten, not read. No file in the set was a real input, so nothing needed relocating instead of
untracking.
Two incidental fixes fall out
test_uniform_1dandtest_uniform_2dbothrmtree'd the same shared output directory — anordering hazard between two test modules that
tmp_pathremoves.test_data_pathfixture wrote their generated FITS into thesource tree through it; they now use
tmp_pathand the fixture is gone.API Changes
None — this PR touches
test_autoarray/and.gitignoreonly. No module underautoarray/ismodified, so there is no public-API surface change and no downstream workspace migration.
Test Plan
baseline on
main(1177/55).git status --porcelainasserted unchanged after each. Thesecond run is what would catch a test that had silently depended on a committed artifact: it
would fail on run 1, not run 2.
find test_autoarray -path "*output_test*"returns nothing after a full run — the tests nolonger write into the source tree at all.
output_test/path (git ls-files | grep output_test).Sibling repos
Checked as the issue asked, and not widened into this PR. Neither PyAutoGalaxy nor PyAutoLens
uses the
output_test/name, and both track zero test-output artifacts — this defect isautoarray-only. PyAutoLens does have a smaller, different problem (its tests write to
test_autolens/{imaging,interferometer}/data_temp/, which its.gitignoredoes not cover — onlythe
integration/copies), filed separately rather than mixed in here.Full API Changes (for automation & release notes)
Removed
test_autoarray/dataset/imaging/test_dataset.py::make_test_data_path— thetest_data_pathpytest fixture, which created
files/array/output_test/in the source tree. Its three consumersnow take
tmp_path. Test-suite-internal; not part of theautoarraypackage.Added
Migration
autoarraypublic symbol is added, removed or changed.Closes #494
Generated by the PyAutoLabs agent workflow.
Generated by Claude Code