The shim test pinned UNSLOTH_COMPILE_LOCATION via env before
importing unsloth_zoo.compiler, but tests/conftest.py runs
`import unsloth` first, which transitively imports
unsloth_zoo.compiler with the default cache path. The shim's later
env-set never took effect on the captured module global, so the
compiler silently wrote artefacts to the default cache and the
per-model file assertion failed under Core (HF=4.57.6 + TRL<1).
Two fixes:
1) After import, mutate the live module globals directly
(UNSLOTH_COMPILE_LOCATION, UNSLOTH_COMPILE_USE_TEMP) so they
reflect the hermetic tmp dir regardless of who imported the
module first. The same pattern is already used in
_compiler_cache_invariants_shim._isolate_cache.
2) test_compile_real_modeling_module no longer re-runs
unsloth_compile_transformers after a sweep already patched the
module. The compile is not idempotent in-process: re-running on
a module whose class forwards were already rewritten corrupts
the inspect source/line cache and the second-pass emitted file
raises IndentationError / OSError "lineno is out of bounds" on
import. The sweep already emitted a valid cache file for every
non-KNOWN_BROKEN model_type, so verify that artefact directly;
trigger a compile only when running this test in isolation.
Verified locally:
pytest -q tests/_zoo_compiler_cache_shim.py (5 passed, 1 skipped)
pytest -q tests/.._real_modeling_module (3 passed)