Commit 7d97d90
Fix test_mode propagation by checking dj.config directly
Root cause: When settings.py is first imported, module-level variables like
test_mode are set from sg_config at import time (line 725). Later, when test
fixtures call load_config(test_mode=True), it updates sg_config._test_mode
and dj.config['custom']['test_mode'], but the module-level variable stays stale.
The _test_mode property in BaseMixin was doing:
from spyglass.settings import test_mode
return test_mode # Returns stale module-level variable!
This caused electrode validation to run during tests even though test_mode
should be True, because it was checking the stale module variable that was
set to False at initial import.
Fix: Changed _test_mode to check dj.config['custom']['test_mode'] directly
instead of importing the module-level variable. This avoids global variables
and ensures we always get the current config state.
This is why PR #1454's electrode validation worked on master but failed when
merged with our branch - subtle import order differences meant our branch
triggered settings import earlier, before fixtures could update test_mode.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent d99d873 commit 7d97d90
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
0 commit comments