From 7b0a6fcd5d27ff7c1ebdc6876e7bffd26db6afe0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 28 Nov 2025 12:03:13 -0500 Subject: [PATCH] Fix test to skip when changelog_entry.yaml is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The versioning workflow consumes changelog_entry.yaml, leaving it empty. This causes the test to fail on the next CI run. Add skip logic for empty files to prevent this. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- changelog_entry.yaml | 4 ++++ .../tests/test_changelog_encoding.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..f825737cd 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Fix changelog encoding test to skip when changelog_entry.yaml is empty after versioning diff --git a/policyengine_uk_data/tests/test_changelog_encoding.py b/policyengine_uk_data/tests/test_changelog_encoding.py index fa8dfd2dd..087aedb70 100644 --- a/policyengine_uk_data/tests/test_changelog_encoding.py +++ b/policyengine_uk_data/tests/test_changelog_encoding.py @@ -34,6 +34,10 @@ def test_changelog_entry_is_valid_utf8(self): # Read as bytes and try to decode as UTF-8 content_bytes = changelog_entry_path.read_bytes() + # Skip if file is empty (happens after versioning workflow consumes it) + if not content_bytes.strip(): + pytest.skip("changelog_entry.yaml is empty") + try: content_bytes.decode("utf-8") except UnicodeDecodeError as e: @@ -56,11 +60,19 @@ def test_changelog_entry_is_valid_yaml(self): content = changelog_entry_path.read_text(encoding="utf-8") + # Skip if file is empty (happens after versioning workflow consumes it) + if not content.strip(): + pytest.skip("changelog_entry.yaml is empty") + try: data = yaml.safe_load(content) except yaml.YAMLError as e: pytest.fail(f"changelog_entry.yaml is not valid YAML: {e}") + # Skip if data is None (empty YAML) + if data is None: + pytest.skip("changelog_entry.yaml is empty") + # Verify structure assert isinstance(data, list), "changelog_entry.yaml must be a list" for entry in data: