Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
32 changes: 23 additions & 9 deletions tests/test_build_docs_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import logging

import pytest

from build_docs import Version, Versions
Expand Down Expand Up @@ -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:
Expand Down