fix: Skip YAML/TOML tests when optional dependencies unavailable
Fixed test failures in CI environments without PyYAML or toml/tomli: **Problem:** - test_parse_yaml_config and test_parse_toml_config were failing in CI - Tests expected ImportError but parse_config_file() doesn't raise it - Instead, it adds error to parse_errors list and returns empty settings - Tests then failed on `assertGreater(len(config_file.settings), 0)` **Solution:** - Check parse_errors for dependency messages after parsing - Skip test if "PyYAML not installed" found in errors - Skip test if "toml...not installed" found in errors - Allows tests to pass locally (with deps) and skip in CI (without deps) **Affected Tests:** - test_parse_yaml_config - now skips without PyYAML - test_parse_toml_config - now skips without toml/tomli **CI Impact:** - Was: 2 failures across all 6 CI jobs (12 total failures) - Now: 2 skips across all 6 CI jobs (expected behavior) These are optional dependencies not included in base install, so skipping is the correct behavior for CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -158,12 +158,14 @@ logging:
|
||||
file_path.write_text(yaml_content)
|
||||
|
||||
# This will skip if PyYAML not available
|
||||
try:
|
||||
self.parser.parse_config_file(config_file)
|
||||
self.assertGreater(len(config_file.settings), 0)
|
||||
except ImportError:
|
||||
self.parser.parse_config_file(config_file)
|
||||
|
||||
# Check if parsing failed due to missing PyYAML
|
||||
if config_file.parse_errors and "PyYAML not installed" in str(config_file.parse_errors):
|
||||
self.skipTest("PyYAML not installed")
|
||||
|
||||
self.assertGreater(len(config_file.settings), 0)
|
||||
|
||||
def test_parse_env_file(self):
|
||||
"""Test parsing .env file"""
|
||||
env_content = """
|
||||
@@ -314,12 +316,14 @@ endpoint = "https://api.example.com"
|
||||
file_path.write_text(toml_content)
|
||||
|
||||
# This will skip if toml/tomli not available
|
||||
try:
|
||||
self.parser.parse_config_file(config_file)
|
||||
self.assertGreater(len(config_file.settings), 0)
|
||||
except ImportError:
|
||||
self.parser.parse_config_file(config_file)
|
||||
|
||||
# Check if parsing failed due to missing toml/tomli
|
||||
if config_file.parse_errors and ("toml" in str(config_file.parse_errors).lower() and "not installed" in str(config_file.parse_errors)):
|
||||
self.skipTest("toml/tomli not installed")
|
||||
|
||||
self.assertGreater(len(config_file.settings), 0)
|
||||
|
||||
|
||||
class TestConfigPatternDetector(unittest.TestCase):
|
||||
"""Tests for ConfigPatternDetector - pattern detection"""
|
||||
|
||||
Reference in New Issue
Block a user