diff --git a/build_docs.py b/build_docs.py index cabfaec..2473fd7 100755 --- a/build_docs.py +++ b/build_docs.py @@ -111,11 +111,13 @@ def from_json(cls, data: dict) -> Versions: status = release["status"] status = Version.SYNONYMS.get(status, status) if status not in Version.STATUSES: - msg = ( - f"Saw invalid version status {status!r}, " - f"expected to be one of {permitted}." + logging.warning( + "Saw invalid version status %r, expected to be one of %s. Context: %s", + status, + permitted, + release, ) - raise ValueError(msg) + continue versions.append(Version(name=name, status=status, branch_or_tag=branch)) return cls(sorted(versions, key=Version.as_tuple)) diff --git a/tests/test_build_docs_versions.py b/tests/test_build_docs_versions.py index 1d8f6dc..8e7e230 100644 --- a/tests/test_build_docs_versions.py +++ b/tests/test_build_docs_versions.py @@ -1,5 +1,7 @@ from __future__ import annotations +import logging + import pytest from build_docs import Version, Versions @@ -57,16 +59,28 @@ def test_from_json() -> None: ] -def test_from_json_error() -> None: +def test_from_json_warning(caplog) -> None: # Arrange - json_data = {"2.8": {"branch": "2.8", "pep": 404, "status": "ex-release"}} - - # Act / Assert - with pytest.raises( - ValueError, - match="Saw invalid version status 'ex-release', expected to be one of", - ): - Versions.from_json(json_data) + json_data = { + "2.8": {"branch": "2.8", "pep": 404, "status": "ex-release"}, + "3.16": { + "branch": "", + "pep": 826, + "status": "", + "first_release": "2027-10-06", + "end_of_life": "2032-10", + "release_manager": "Savannah Ostrowski", + }, + } + + # Act + with caplog.at_level(logging.WARNING): + versions = list(Versions.from_json(json_data)) + + # Assert: both should be skipped + assert versions == [] + assert "Saw invalid version status 'ex-release'" in caplog.text + assert "Saw invalid version status ''" in caplog.text def test_current_stable(versions) -> None: