Commit e1eb340
authored
Fix sys.modules leak in offline cross-sync test (#926)
reload_zoo popped unsloth_zoo from sys.modules and re-imported it without
restoring the original module. The reimport installs a fresh package object
that lacks lazily-bound submodule attributes such as vision_utils, so once
this fixture had run, any later test resolving a submodule through a string
path (monkeypatch.setattr("unsloth_zoo.vision_utils....", ...)) failed with
AttributeError. This surfaced as 5 errors in test_vision_collator_audio.py in
full-suite runs while every test passed in isolation.
Snapshot the unsloth_zoo* modules and restore them on teardown so the reload
no longer leaks a half-initialized package into the rest of the session.
Also patch the imported module object directly in the audio collator test
instead of the string path, so it stays robust to any future sys.modules
pollution.1 parent 385f9ef commit e1eb340
2 files changed
Lines changed: 32 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
34 | 49 | | |
35 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
36 | 59 | | |
37 | 60 | | |
38 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | | - | |
| 516 | + | |
| 517 | + | |
512 | 518 | | |
513 | 519 | | |
514 | 520 | | |
| |||
0 commit comments