Repository navigation
Tests start with non-dimensional scaling off (#1001) - #1045
Conversation
set_reference_quantities switches the global scaling flag on, and reset_default_model leaves it as it was: test_0816 pins that the flag is global, not the model's. conftest's isolation fixtures reset only the model, so a test that set reference quantities handed the next test a model with none and scaling still on. Both isolation fixtures now go through one helper that resets the model and switches the flag off. The library is unchanged; whether reset_default_model itself should clear the flag is left open on #1001. test_0743 runs two tests under the live conftest with pytester: the second saw the flag on before this change. Underworld development team with AI support from Claude Code
Adversarial review (H1 worker), from
|
| conftest | test_0743 | module-scope check |
|---|---|---|
| branch | pass | pass |
| base (8f0ed0a) | fail | fail |
| helper without the flag line | fail | fail |
| function fixture doesn't call the helper | fail | pass |
| module fixture doesn't call the helper | pass | fail |
| lines swapped | pass | pass |
Findings
| # | sev | finding |
|---|---|---|
| F1 | Low | test_0743 pins only the function-scoped reset. If isolate_module_state stops calling the helper, test_0743 still passes, yet a module-scoped fixture is then built with scaling on after a module that set references. That is the #567 route, and the reason the module fixture exists. A second pytester case (two modules, and a module-scoped fixture that records the flag) closes it. Our mut/*/test_m1_sets_refs.py and test_m2_module_fixture.py are that case. |
| F2 | Info | The collection guard's fingerprint (_global_state_fingerprint) records references, strict units and the object count, but not the scaling flag. A module that calls use_nondimensional_scaling(True) at import would pass the guard. The branch's module-scoped reset now cleans up after it, so this is not a defect, but adding the flag to the fingerprint would make the guard complete. |
| F3 | Info [read] | set_reference_quantities also writes the global COEFFICIENTS dict in scaling/_scaling.py, and reset_default_model does not clear that either. It is the same class as #1001 but a different global, and outside this branch. Worth a line on #1001. |
Merge conditions
- None blocking. F1 should be added as a test, before or after opening.
Issue verdicts
- reset_default_model leaves the non-dimensional scaling flag on, so it leaks between tests #1001, the test-pollution half: fixed by this branch, by test_0743 and the runs above.
- reset_default_model leaves the non-dimensional scaling flag on, so it leaks between tests #1001, the library half (
reset_default_modelleaves the flag on): still live, deliberately. test_0816 pins it,
and the ruling is Louis's.
What we could not test
- The full suite under xdist's own distribution at CI worker counts. We ran serially and at np 2 only.
- The last 69 serial tests in collection order (test_1081 onward), because of the two stalls above. Those files use
only function-scoped fixtures that reset the flag themselves (reset_model_statein 1100/1110/1120/jit_cache) or
set the references per test (1148). We ran 1148 per file at np 2, with identical outcomes. - F3: [read] only.
Underworld development team with AI support from Claude Code
A test that sets reference quantities no longer leaves non-dimensional scaling switched on for the next test. This fixes the test-isolation half of #1001.
What was wrong
set_reference_quantitiesswitches the global scaling flag on.reset_default_modelleaves the flag as it was. That behaviour is deliberate:test_0816::test_flag_state_persistencepins it, because the flag is global and does not belong to the model.conftest's isolation fixtures reset only the model. So a test that set reference quantities handed the next test a fresh model with none, but with scaling still on.The change
Both isolation fixtures in
tests/conftest.py, the per-test one and the module-scoped one (#567), now call one helper,_reset_global_units_state. It resets the model and switches the flag off. The library is unchanged.Left open on #1001
Should
reset_default_modelitself switch the flag off? Doing so breakstest_0816::test_flag_state_persistence, which asserts the opposite, so it is the maintainer's call. #1001 stays open for that.Tests
tests/test_0743_reset_default_model_clears_scaling.py(tier B) runs two tests under the live conftest with pytester. The second test saw the flag on before this change. It fails on 8f0ed0a, and also fails with the flag line removed.Checklist (UW3 Style Charter)
level_*andtier_*markersUnderworld development team with AI support from Claude Code