Commit b9425e0
committed
fix(test): restore the parent-package attribute after a blocked re-import
The last two CI failures. test_routing.py's live-detection cases failed only in
a full-suite run, and which cases failed depended on whether the machine had a
GPU - so they passed locally and failed on the runner, which read as a CI-only
mystery. It was an ordering bug.
`_reimport_without` deletes a submodule from sys.modules, re-imports it with a
dependency blocked, and restores sys.modules in a finally. But importing
`pkg.sub` also rebinds the fresh module onto its parent as `pkg.sub`, and
nothing undid that. The throwaway module therefore outlived the helper as an
attribute of the real package, permanently disagreeing with sys.modules for the
rest of the session:
sys.modules["qector_decoder_v3.gpu_backend"] -> original
qector_decoder_v3.gpu_backend -> throwaway
`routing` holds `from . import gpu_backend as _gb`, bound at import to the
original, and that is what `HardwareProfile.detect()` calls. monkeypatch reached
the throwaway - by either spelling, since pytest's resolve() walks parents with
getattr, which is why switching to the dotted-path form in b0f5456 changed
nothing. The patch was applied to a module nothing under test read, so detect()
kept reporting real hardware.
Restore the parent attribute alongside sys.modules.
Verified by causation, not by hope: with the fix, the polluting file followed by
test_routing passes 91/91; with it stashed, the same command fails 2 - locally
the [False-*] cases, on CI the [*-True] ones, the difference being the host's
actual GPU, exactly as the mechanism predicts.
Also corrects the comment added in b0f5456, whose explanation was wrong.1 parent 1a1af6e commit b9425e0
2 files changed
Lines changed: 32 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
0 commit comments