Skip to content

Commit a0e6d6f

Browse files
CopilotCyberSecDef
andauthored
Make config default tests deterministic by clearing env vars and reloading module
Agent-Logs-Url: https://github.com/CyberSecDef/NovelForge/sessions/f855c09b-c821-4cac-a8ba-53e869009651 Co-authored-by: CyberSecDef <17597068+CyberSecDef@users.noreply.github.com>
1 parent 8f03266 commit a0e6d6f

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

tests/test_length_enforcement.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,25 @@ def mock_llm(msgs, action=""):
259259
class TestLengthEnforcementConfig:
260260
"""Verify config constants exist and have sensible defaults."""
261261

262-
def test_chapter_min_length_pct_default(self):
262+
def test_chapter_min_length_pct_default(self, monkeypatch):
263+
import importlib
263264
import novelforge.config as cfg
264-
assert cfg.CHAPTER_MIN_LENGTH_PCT == 85
265-
266-
def test_max_expansion_attempts_default(self):
265+
monkeypatch.delenv("CHAPTER_MIN_LENGTH_PCT", raising=False)
266+
importlib.reload(cfg)
267+
try:
268+
assert cfg.CHAPTER_MIN_LENGTH_PCT == 85
269+
finally:
270+
importlib.reload(cfg)
271+
272+
def test_max_expansion_attempts_default(self, monkeypatch):
273+
import importlib
267274
import novelforge.config as cfg
268-
assert cfg.MAX_EXPANSION_ATTEMPTS == 2
275+
monkeypatch.delenv("MAX_EXPANSION_ATTEMPTS", raising=False)
276+
importlib.reload(cfg)
277+
try:
278+
assert cfg.MAX_EXPANSION_ATTEMPTS == 2
279+
finally:
280+
importlib.reload(cfg)
269281

270282
def test_chapter_min_length_pct_in_all(self):
271283
import novelforge.config as cfg

0 commit comments

Comments
 (0)