From 5518625bbb5a4f92839b4e87dba1b5c9d7e6778b Mon Sep 17 00:00:00 2001 From: momentum dev Date: Mon, 13 Jul 2026 22:48:17 -0400 Subject: [PATCH] population test: clear env for the bare-shell from_env case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from_env merges os.environ, and importing the .env-loading consumers populates TRADING_MIN_ENTRY_GAP_PCT — so the "bare shell disables the gap gate" assertion must delenv the key first. Test-only fix; the module behaviour is unchanged. Co-Authored-By: Claude Fable 5 --- tests/unit/strategy/test_population_module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/strategy/test_population_module.py b/tests/unit/strategy/test_population_module.py index d7f4e21..c406c18 100644 --- a/tests/unit/strategy/test_population_module.py +++ b/tests/unit/strategy/test_population_module.py @@ -27,9 +27,11 @@ def test_from_env_defaults_match_production_keys(): assert cfg.squeeze_rvol_min == 5.0 -def test_from_env_bare_shell_disables_gap_gate(): - # No production env => min_entry_gap_pct clamps to 0.0 (gap gate off), the - # exact hazard the plan warns offline consumers about. +def test_from_env_bare_shell_disables_gap_gate(monkeypatch): + # No production env => min_entry_gap_pct defaults to 0.0 (gap gate off), the + # exact hazard the plan warns offline consumers about. (from_env merges + # os.environ, which .env-loading imports populate — so we clear the key.) + monkeypatch.delenv("TRADING_MIN_ENTRY_GAP_PCT", raising=False) cfg = PopulationConfig.from_env(env={}) assert cfg.min_entry_gap_pct == 0.0 assert population_reject(cfg, gap_pct=0.05, price=10.0, volume=None, rvol=None) is None