Repository navigation
Description
tests/conftest.py now fingerprints the process state around each test module's
import and fails the run when a module moves it (#575). Eighteen modules already
do, so they are exempted by name in _KNOWN_COLLECTION_TIME_WORK — a ratchet
that stops the practice spreading, not an approval of it. This issue is the list.
Why module-level work is not merely untidy
pytest imports a module in order to collect it, so anything at module level runs
before any test, any fixture, and any isolation conftest.py provides. Two
defects reached development that way:
- Three point-locator tests fail when xdist worker count changes the file grouping #567 — a module switched the units system on at import, and the first
module-scoped fixture in that worker built its mesh under dimensional
coordinates. Sampled 2.9 million times too far apart; it looked like a
parallelism bug and blocked CI parallelism for days. - test_0050_utils.py runs two Stokes solves at module scope — pytest COLLECTION executes them and whole-directory runs hang silently #505 — a module ran two Stokes solves at import, so
--collect-onlysat
insideSNESSolvelooking like a silent death.
A module that builds a mesh at import has not failed yet; it has built its mesh
under whatever global state the previously collected module left behind.
The list
Fix first, because it is the only one that moves the units state
(uw.use_strict_units(False) at line 28, before three meshes and fourteen
variables — the #567 mechanism exactly):
-
tests/test_0601_mesh_vector_calc.py
The rest build objects at import:
-
tests/parallel/test_0765_internal_boundary_integral_mpi.py -
tests/test_0004_pointwise_fns.py -
tests/test_0005_IndexSwarmVariable.py -
tests/test_0501_integrals.py -
tests/test_0502_boundary_integrals.py -
tests/test_0504_projections.py -
tests/test_0810_amr_swarm_migration_regression.py -
tests/test_0830_mesh_adapt_variable_transfer.py -
tests/test_1000_poissonCart.py -
tests/test_1000_poissonNaturalBC.py -
tests/test_1001_poissonSph.py -
tests/test_1004_DarcyCartesian.py -
tests/test_1010_stokesCart.py -
tests/test_1011_stokesSph.py -
tests/test_1014_stokes_multigrid.py -
tests/test_1014_stokes_shell_nullspace.py -
tests/test_1050_VEstokesCart.py
The fix, per module
Move the module-level objects into a scope="module" fixture and take it as an
argument. tests/test_0050_utils.py, test_0120_data_property_access.py and
test_0130_field_creation.py were converted this way in the same PR and are the
worked examples. Delete the entry from _KNOWN_COLLECTION_TIME_WORK in the same
commit — the guard then holds that module.
Adjacent
scripts/test.sh disables tests/test_06*py wholesale ("regression tests need
validation"), which is why test_0601's import-time units flip has never been
noticed by CI: it is collected by any whole-directory run but never executed by
ours. That is a coverage gap for #570.
Underworld development team with AI support from Claude Code
Activity
Test modules must not build state while being collected
lmoresi commentedon Oct 5, 2026
Re-verified still live on
development(1391e4aa), so the next session does not have to re-derive it: the ratchet intests/conftest.py:117still holds all 18 entries the title names, withtest_0601_mesh_vector_calc.py— the one that moves units state at import, the #567 mechanism itself — still among them. Nothing has come off the list.Checked as part of the backlog sweep (#819); no fix here.
lmoresi commentedon Nov 13, 2026
Probe-pass verdict: still live on development 01dec8d.
_KNOWN_COLLECTION_TIME_WORKintests/conftest.pystill holds all 18 entries, includingtest_0601_mesh_vector_calc.py, which moves the units state at import. Size M: 18 mechanical conversions to module-scoped fixtures, test_0601 first.Underworld development team with AI support from Claude Code