"""Release notes come from CHANGELOG.md (Keep a Changelog headings).""" from __future__ import annotations from napalm_standard.changelog import changelog_section TEXT = """\ # Changelog ## [Unreleased] - not yet ## [1.2.0] - 2026-10-22 ### Added - Interfaces. --- ## [1.1.0] - 2026-10-01 - Facts. """ def test_the_section_runs_to_the_next_version_heading() -> None: assert changelog_section(TEXT, "1.2.0") == "### Added\n- Interfaces." def test_a_leading_v_is_ignored() -> None: assert changelog_section(TEXT, "v1.1.0") == "- Facts." def test_an_unknown_version_has_no_section() -> None: assert changelog_section(TEXT, "9.9.9") is None def test_an_empty_section_has_none() -> None: assert changelog_section("## [1.0.0] - x\n\n## [0.9.0] - y\n- a\n", "1.0.0") is None def test_a_heading_without_brackets_is_not_a_version_heading() -> None: assert changelog_section("## 1.0.0\n\n- a\n", "1.0.0") is None def test_the_last_section_runs_to_the_end() -> None: assert changelog_section("## [1.0.0] - x\n- a\n- b", "1.0.0") == "- a\n- b"