tests.test_changelog moduleΒΆ

Tests for repomatic.changelog: parsing and updating the changelog.

tests.test_changelog.SAMPLE_CHANGELOG = '# Changelog\n\n## [`1.2.3` (unreleased)](https://github.com/user/repo/compare/v1.2.2...main)\n\n> [!WARNING]\n> This version is **not released yet** and is under active development.\n\n- Add new feature.\n- Fix bug.\n\n## [`1.2.2` (2024-01-15)](https://github.com/user/repo/compare/v1.2.1...v1.2.2)\n\n- Previous release.\n'ΒΆ

Reusable changelog fixture for freeze tests.

tests.test_changelog.test_changelog_update(version, initial, modified, updated)[source]ΒΆ

The update reports whether it added an entry.

An unchanged changelog compares against it: the CLI exits early on False.

tests.test_changelog.test_freeze()[source]ΒΆ

Test that freeze applies all three operations.

tests.test_changelog.test_freeze_idempotent()[source]ΒΆ

Test that freezing an already-frozen changelog is a no-op.

tests.test_changelog.test_freeze_file(tmp_path)[source]ΒΆ

Test that freeze_file freezes a changelog on disk.

tests.test_changelog.test_freeze_file_already_released(tmp_path)[source]ΒΆ

Test that freeze_file is a no-op for released changelogs.

tests.test_changelog.test_freeze_file_missing(tmp_path)[source]ΒΆ

Test that freeze_file handles missing files gracefully.

tests.test_changelog.DECOMPOSE_CHANGELOG = '# Changelog\n\n## [`3.0.0` (unreleased)](https://github.com/user/repo/compare/v2.0.0...main)\n\n> [!WARNING]\n> This version is **not released yet** and is under active development.\n\n- New feature.\n\n## [`2.0.0` (2026-02-01)](https://github.com/user/repo/compare/v1.0.0...v2.0.0)\n\n> [!NOTE]\n> `2.0.0` is available on [🐍 PyPI](https://pypi.org/project/pkg/2.0.0/).\n\n> [!CAUTION]\n> `2.0.0` has been [yanked from PyPI](https://pypi.org/project/pkg/2.0.0/).\n\n- Breaking change.\n- New API.\n\n## [`1.0.0` (2025-12-01)](https://github.com/user/repo/compare/v0.9.0...v1.0.0)\n\n- Initial release.\n'¢

Changelog with all element types for decompose tests.

tests.test_changelog.test_decompose_version(version, expected_date, expected_url, contains, equals)[source]ΒΆ

Decompose versions with varying element combinations.

tests.test_changelog.test_decompose_version_extracts_editorial_admonitions()[source]ΒΆ

Editorial admonitions (e.g. [!TIP]) land in editorial_admonition.

tests.test_changelog.test_decompose_version_multiple_editorial_admonitions()[source]ΒΆ

Multiple editorial admonitions are joined in editorial_admonition.

tests.test_changelog.test_decompose_version_editorial_with_auto_generated()[source]ΒΆ

Editorial and auto-generated admonitions are correctly separated.

tests.test_changelog.test_decompose_version_empty()[source]ΒΆ

Version not found returns empty elements.

tests.test_changelog.test_replace_section(version, new_section, expected, present, absent)[source]ΒΆ

Test replacing an entire section (heading + body).

tests.test_changelog.test_extract_all_releases(content, expected)[source]ΒΆ

Test extraction of released versions from varying changelogs.

tests.test_changelog.test_extract_all_version_headings()[source]ΒΆ

Test that all versions (released and unreleased) are extracted.

tests.test_changelog.test_extract_all_version_headings_empty()[source]ΒΆ

Test extraction from an empty changelog.

tests.test_changelog.test_insert_version_section()[source]ΒΆ

Test inserting a placeholder section for a missing version.

tests.test_changelog.test_insert_version_section_idempotent()[source]ΒΆ

Test that inserting an already-present version is a no-op.

tests.test_changelog.test_insert_version_section_at_end()[source]ΒΆ

Test inserting a version older than all existing ones.

tests.test_changelog.test_update_comparison_base(version, new_base, expected, present, absent)[source]ΒΆ

Test replacing the comparison base in a version heading.

tests.test_changelog.DEV_ONLY_CHANGELOG = '# Changelog\n\n## [`1.0.0.dev0` (unreleased)](https://github.com/user/repo/compare/v0.9.0...main)\n\n> [!WARNING]\n> This version is **not released yet** and is under active development.\n'ΒΆ

Changelog mid-development cycle, carrying no final-release heading.

tests.test_changelog.FROZEN_CHANGELOG = '# Changelog\n\n## [`1.2.3` (2026-03-01)](https://github.com/user/repo/compare/v1.2.2...v1.2.3)\n\n- Add papaya sorting.\n'ΒΆ

Changelog whose newest section is already frozen, ready for a post-release bump.

tests.test_changelog.test_insert_version_section_orders_against_dev_headings()[source]ΒΆ

A .devN heading takes part in the insertion-point scan.

The published 1.0.0 outranks the 1.0.0.dev0 section still sitting in the changelog, so it belongs above it. A scan blind to development headings finds no lower version, falls through to the append-at-end branch, and files the newest release at the bottom.

tests.test_changelog.test_update_retargets_comparison_url_to_default_branch(kwargs, expected)[source]ΒΆ

The new unreleased entry points at the branch the caller names.

freeze retargets this same URL back to a tag, so a hard-coded main here leaves any repository on another default branch unable to round-trip.

tests.test_changelog.test_freeze_warns_when_section_is_missing(caplog)[source]ΒΆ

A version with no changelog section warns instead of quietly no-opping.

tests.test_changelog.test_freeze_already_frozen_stays_silent(caplog)[source]ΒΆ

The idempotent no-op path must not warn, or every re-run cries wolf.

tests.test_changelog.test_rendered_sections_are_an_mdformat_fixed_point(tmp_path, monkeypatch)[source]ΒΆ

Every section this module renders must survive format-markdown intact.

fix-changelog writes changelog.md and format-markdown reformats the same file on the same push. When the two disagree on the canonical layout they ping-pong: one job rewrites the section, the next reformats it, each opening its own PR, and neither converges.

Both renderings are exercised, because they fail differently. The inserted placeholder leaves every optional admonition slot of the release-notes template empty, which is where stray blank-line runs collect; the regenerated section fills the availability slot with a GFM alert, which only mdformat_gfm_alerts knows how to reflow.

Verified through the write path rather than mdformat --check, whose verdict is unreliable for a tool carrying a post_process fixup (see verify_via_write_path()).

Marked once: it resolves mdformat and its fifteen plugins through uvx, so one runner suffices.

tests.test_changelog.test_decomposition_follows_every_content_change()[source]ΒΆ

The cached sections are dropped whenever the content changes.

tests.test_changelog.test_decomposition_hands_out_copies()[source]ΒΆ

Changing a returned decomposition leaves the next one untouched.

tests.test_changelog.test_insert_version_section_ignores_unparsable_versions()[source]ΒΆ

A version PEP 440 refuses takes no part in the ordering.

tests.test_changelog.test_version_elements_queries(elements, has_body, tag_range)[source]ΒΆ
tests.test_changelog.test_version_elements_bullets(changes, expected)[source]ΒΆ

Each top-level - starts one entry; wraps and sub-bullets fold into it.

tests.test_changelog.test_tag_prefixed_headings_are_found_and_stripped()[source]ΒΆ

A heading written with the v of a tag is invisible until stripped.