Skip to content

Commit 62be0ba

Browse files
committed
Update test for missing FQ_CONFIG env var to check for default config usage and warning output
1 parent f2afcd3 commit 62be0ba

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tests/test_routes.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,32 @@ class FQConfigTestCase(unittest.TestCase):
1818
"""Tests for configuration validation."""
1919

2020
def test_missing_fq_config_env_var(self):
21-
"""Test that missing FQ_CONFIG environment variable raises an error."""
21+
"""Test that missing FQ_CONFIG environment variable uses default config."""
2222
# Ensure FQ_CONFIG is not set
2323
env_backup = os.environ.pop("FQ_CONFIG", None)
2424
try:
25-
with self.assertRaises(EnvironmentError) as context:
26-
# Re-import asgi module to trigger the check
27-
import importlib
28-
import asgi
29-
30-
importlib.reload(asgi)
31-
self.assertIn("FQ_CONFIG", str(context.exception))
25+
# Capture stdout to verify warning message
26+
from io import StringIO
27+
import sys
28+
captured_output = StringIO()
29+
sys.stdout = captured_output
30+
31+
# Re-import asgi module to trigger the check
32+
import importlib
33+
import asgi
34+
importlib.reload(asgi)
35+
36+
sys.stdout = sys.__stdout__
37+
38+
# Verify warning was printed
39+
output = captured_output.getvalue()
40+
self.assertIn("FQ_CONFIG", output)
41+
self.assertIn("default config path", output)
3242
finally:
3343
# Restore the environment variable if it was set
3444
if env_backup is not None:
3545
os.environ["FQ_CONFIG"] = env_backup
46+
sys.stdout = sys.__stdout__
3647

3748
def test_config_file_not_found(self):
3849
"""Test that non-existent config file raises FileNotFoundError."""

0 commit comments

Comments
 (0)