Skip to content

Commit 33a23cf

Browse files
committed
test: make the suite hermetic against the ambient small-datasets flag
Every FITS the stack writes now carries a SMALLDAT card whose value tracks PYAUTO_SMALL_DATASETS at write time. Several tests write into TRACKED fixture paths -- a pre-existing pattern, 14 such files across this repo and PyAutoNerves -- so the bytes those tests produce had become a function of the shell: running the suite with PYAUTO_SMALL_DATASETS=1 exported, which should_simulate's own docstring calls the default for most harness runs, passed but left the working tree dirty. Verified against fresh main worktrees that this dirtying is introduced by the stamp and is not pre-existing. An autouse fixture clearing the var restores the property the stamp took away -- test output is a function of the test, not of the environment -- in one place, rather than by rewriting every fixture-writing test in a PR about a header card. Tests that need a regime set it with monkeypatch.setenv in their body, which runs after the fixture and wins. No test depended on the ambient value. Verified: 1090 passed and tree clean both with the var exported and unset (the 11 failures are pre-existing missing-pynufft, identical on main). Found by three independent review lenses, each reproducing it separately.
1 parent 449d991 commit 33a23cf

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test_autoarray/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,26 @@ def pytest_collection_modifyitems(config, items):
317317
)
318318
if needs_nufftax:
319319
item.add_marker(skip_nufftax)
320+
321+
322+
@pytest.fixture(autouse=True)
323+
def _regime_independent_test_output(monkeypatch):
324+
"""
325+
Clear ``PYAUTO_SMALL_DATASETS`` for every test unless the test sets it.
326+
327+
Since PyAutoNerves#153 every FITS the stack writes carries a ``SMALLDAT``
328+
card whose value tracks this env var at write time. Several tests write into
329+
**tracked** fixture paths (14 of them across this repo and PyAutoNerves --
330+
a pre-existing pattern), so without this the bytes those tests produce
331+
depend on the ambient environment: run the suite in a shell exporting
332+
``PYAUTO_SMALL_DATASETS=1`` -- which ``should_simulate``'s own docstring calls
333+
the default for most harness runs -- and the suite passes but leaves the
334+
working tree dirty.
335+
336+
Pinning it here restores the property the stamp took away, that test output
337+
is a function of the test and not of the shell, and does so in one place
338+
rather than by rewriting every fixture-writing test. Tests that need a
339+
regime set it with ``monkeypatch.setenv`` in their body, which runs after
340+
this fixture and wins.
341+
"""
342+
monkeypatch.delenv("PYAUTO_SMALL_DATASETS", raising=False)

0 commit comments

Comments
 (0)