Repository navigation
Commit 20b7e8f
committed
fix: avoid re-executing modules between @djc_test cycles (#1598 root cause)
#1630 patched the registry-corruption symptom from #1598, but the
underlying trigger remained: `_clear_djc_global_state` popped every
entry from `LOADED_MODULES` out of `sys.modules`, including modules
that had already been imported before the test ran. The next test's
`autodiscover()` then re-executed those modules, producing a fresh
class object with the same `class_id` as the original - exactly the
input PR #1630 had to defend against.
Snapshot `sys.modules.keys()` in `_wrapper_impl` and pass it through
to `_clear_djc_global_state`, which now only pops `LOADED_MODULES`
entries that were absent from the snapshot. Modules the test itself
imported are still cleared; modules carried in from production
startup or earlier tests stay put.
This implements Options B/C suggested in #1598.1 parent 1c972de commit 20b7e8f
2 files changed
Lines changed: 45 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
336 | 340 | | |
337 | 341 | | |
338 | 342 | | |
| |||
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
| 349 | + | |
345 | 350 | | |
346 | 351 | | |
347 | 352 | | |
| |||
457 | 462 | | |
458 | 463 | | |
459 | 464 | | |
| 465 | + | |
460 | 466 | | |
461 | 467 | | |
462 | 468 | | |
| |||
540 | 546 | | |
541 | 547 | | |
542 | 548 | | |
543 | | - | |
544 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
545 | 554 | | |
546 | 555 | | |
547 | 556 | | |
548 | | - | |
| 557 | + | |
| 558 | + | |
549 | 559 | | |
550 | 560 | | |
551 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
0 commit comments