Commit 0fbaffe
Gereon Elvers
Fix CI: scope sys.modules pops in overlay tests under monkeypatch.delitem
test_overlay_modules_are_discovered_without_registration and
test_overlay_modules_can_override_public_modules used plain sys.modules.pop
to clear pnpl entries before re-importing them through a tmp_path overlay.
That tmp_path overlay only contains a few overlay files (no top-level
pnpl/__init__.py), so re-importing pnpl resolved it as a namespace
package — and because the pop was permanent, that namespace-loaded pnpl
lingered in sys.modules after the test and poisoned every later test
that re-imported pnpl, pnpl.datasets, or pnpl.tasks.
Locally, pytest happens to add the project root to sys.path which lets
PathFinder shortcut to the real pnpl/__init__.py before the namespace
fallback kicks in, masking the leak. CI did not get that shortcut, so
the four namespace-related tests have been failing since refactor was
merged into main.
Switching the pops to monkeypatch.delitem(sys.modules, ..., raising=False)
makes pytest restore the original modules at teardown, so the leak is
gone. Verified: pytest passes 13/13 from a non-project cwd, which
previously reproduced the four CI failures.1 parent 5b5fb3f commit 0fbaffe
1 file changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | | - | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | | - | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
0 commit comments