Coverage for tests/test_release_notes.py: 100.00%
9 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-02 00:26 +0200
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-02 00:26 +0200
1"""Tests for the release notes feature."""
3from __future__ import annotations
5from typing import TYPE_CHECKING
7from git_changelog.cli import get_release_notes
9if TYPE_CHECKING:
10 from pathlib import Path
13def test_getting_release_notes(tmp_path: Path) -> None:
14 """Get release notes from existing changelog.
16 Parameters:
17 tmp_path: Temporary directory (pytest fixture).
18 """
19 changelog_lines = [
20 "# Changelog",
21 "Header.",
22 "<!-- insertion marker -->",
23 "## [2.0.0](https://example.com)",
24 "Contents 2.0.",
25 "<!-- insertion marker -->",
26 "## [1.0.0](https://example.com)",
27 "Contents 1.0",
28 ]
29 changelog = tmp_path.joinpath("changelog.md")
30 changelog.write_text("\n\n".join(changelog_lines))
31 expected = "\n\n".join(changelog_lines[3:5])
32 assert get_release_notes(input_file=changelog) == expected