Skip to content

Commit e2bfe05

Browse files
edenoclaude
andcommitted
Fix test_mode propagation by updating module-level variables
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 but the module-level variable stays stale. The _test_mode property in BaseMixin does: 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: Update module-level variables (test_mode, debug_mode) at the end of load_config() so they reflect 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 e2bfe05

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/spyglass/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ def load_config(
320320

321321
self._set_dj_config_stores()
322322

323+
# Update module-level variables so they reflect current config state
324+
# This is critical for test_mode to work correctly when load_config
325+
# is called with test_mode=True after module import
326+
global test_mode, debug_mode
327+
test_mode = self._test_mode
328+
debug_mode = self._debug_mode
329+
323330
return self._config
324331

325332
def _load_env_vars(self) -> dict:

0 commit comments

Comments
 (0)