From 24634bc8b4d5a9a954951f37075f58bf1036fcd7 Mon Sep 17 00:00:00 2001 From: yusyus Date: Mon, 12 Jan 2026 22:28:06 +0300 Subject: [PATCH] fix: Skip YAML/TOML tests when optional dependencies unavailable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/test_config_extractor.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/test_config_extractor.py b/tests/test_config_extractor.py index d9bc87d..b5a87ce 100644 --- a/tests/test_config_extractor.py +++ b/tests/test_config_extractor.py @@ -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"""