tests.test_pr_body moduleΒΆ
Tests for PR body generation.
- tests.test_pr_body.PR_TEMPLATES = ('bump-version', 'fix-changelog', 'fix-typos', 'fix-vulnerable-deps', 'format-images', 'format-json', 'format-markdown', 'format-pyproject', 'format-python', 'format-shell', 'prepare-release', 'sample-metrics', 'scan-virustotal', 'squashed-release', 'sync-action-pins', 'sync-bumpversion', 'sync-dep-sources', 'sync-gitignore', 'sync-mailmap', 'sync-repomatic', 'sync-repomatic-upgrade', 'sync-runner-images', 'sync-tool-versions', 'sync-uv-lock', 'sync-workflow-pins', 'update-dep-graph', 'update-docs')ΒΆ
The templates that front a pull request or an issue: the ones with a title.
- tests.test_pr_body.github_env(monkeypatch)[source]ΒΆ
Populate the full
GITHUB_*environment a workflow run would provide.Metadatareads these lazily, so every test that renders a metadata block or a refresh tip needs the whole set in place before it builds one.
- tests.test_pr_body.no_github_env(monkeypatch)[source]ΒΆ
Clear the
GITHUB_*environment, as on a developer machine.
- tests.test_pr_body.test_generate_metadata_block_all_vars(github_env)[source]ΒΆ
Metadata block includes all expected fields when env vars are set.
- tests.test_pr_body.test_generate_metadata_block_rerun(github_env, monkeypatch)[source]ΒΆ
Re-run by entry appears when triggering actor differs from actor.
- tests.test_pr_body.test_generate_metadata_block_docs_entry(github_env)[source]ΒΆ
The documentation deep link leads the list when a template provides one.
- tests.test_pr_body.test_generate_metadata_block_minimal_vars(no_github_env)[source]ΒΆ
Graceful degradation when most env vars are unset.
- tests.test_pr_body.test_generate_refresh_tip_with_workflow_ref(github_env)[source]ΒΆ
Tip includes workflow dispatch URL when env vars are set.
- tests.test_pr_body.test_generate_refresh_tip_without_workflow_ref(no_github_env)[source]ΒΆ
Tip is empty when workflow ref is unavailable.
Every pull request body ends on exactly one attribution footer.
The metadata block carries it, so a template that rendered its own on top would show it twice.
- tests.test_pr_body.test_render_pr_without_a_template(no_github_env)[source]ΒΆ
A prefix alone renders a body, and no title nor commit message.
- tests.test_pr_body.test_render_pr_links_the_template_documentation(no_github_env)[source]ΒΆ
The metadata block names the template and links its jobβs section.
- tests.test_pr_body.test_render_pr_extra_args_win_over_flags(no_github_env)[source]ΒΆ
An explicit argument supersedes the dedicated flag of the same name.
- tests.test_pr_body.test_render_pr_names_the_missing_argument(no_github_env)[source]ΒΆ
An argument nothing supplies fails with the flag that would supply it.
- tests.test_pr_body.test_render_pr_reads_the_version_from_bumpversion(no_github_env)[source]ΒΆ
Without
--version, the bumpversion version is used, its.devNstripped.
- tests.test_pr_body.test_render_pr_without_a_version_names_the_missing_config(no_github_env)[source]ΒΆ
No
--versionand no bumpversion config fails with what is missing.
- tests.test_pr_body.test_render_pr_fills_the_release_checklist_from_one_lookup(github_env)[source]ΒΆ
Both review steps come from one releases lookup, after the readiness verdict.
- tests.test_pr_body.test_render_pr_reads_the_diff_table_from_its_file(no_github_env, tmp_path, monkeypatch)[source]ΒΆ
A report reaches the body through the file its
_FILEvariable names.
- tests.test_pr_body.FAKE_FOOTER = '<details>metadata</details>\n\n***\n\nGenerated with [repomatic](https://github.com/kdeldycke/repomatic)'ΒΆ
Simulates
generate_pr_metadata_block(Metadata())output for unit tests.
- tests.test_pr_body.test_build_pr_body_with_prefix(no_github_env)[source]ΒΆ
Prefix is prepended with triple newline separator.
- tests.test_pr_body.test_build_pr_body_with_tip(github_env)[source]ΒΆ
Tip is inserted between prefix and footer when env vars are set.
- tests.test_pr_body.test_build_pr_body_empty_prefix(no_github_env)[source]ΒΆ
Empty prefix without tip still includes footer and metadata.
- tests.test_pr_body.test_build_pr_body_trims_oversized_prefix(github_env)[source]ΒΆ
An oversized prefix is trimmed so the tail always survives.
GitHub truncates oversized bodies from the end, which silently drops the refresh tip, metadata block, and attribution footer (the fate of huge
sync-uv-locktables). The prefix is trimmed instead, on line boundaries, with a caution admonition marking the cut.
- tests.test_pr_body.test_build_pr_body_under_limit_untouched(github_env)[source]ΒΆ
A body under the limit is returned without any truncation notice.
An oversized issue body is trimmed above the footer, which survives.
Oversized issue bodies make
gh issue createandgh issue editfail outright, so the guard rewrites the body to fit before it reaches the API.
- tests.test_pr_body.test_fit_github_body_small_unchanged()[source]ΒΆ
A body under the limit passes through byte-for-byte.
A footerless oversized body is trimmed too, without inventing a footer.
- tests.test_pr_body.test_version_dev_suffix_stripping(version, expected)[source]ΒΆ
The
.devNsuffix is stripped from auto-detected versions.Exercises the shared helper both
pr-body --version autoandrepomatic initβs default pin route through, rather than restating its regex here: a test that spells the pattern itself passes no matter what the callers do.
- tests.test_pr_body.test_cli_template_file(tmp_path, monkeypatch)[source]ΒΆ
--template-filerenders a markdown body from an external template.
- tests.test_pr_body.test_cli_prefix_file_reads_the_prefix_from_disk(tmp_path, monkeypatch)[source]ΒΆ
--prefix-filecarries a report too large to pass as an argument.
- tests.test_pr_body.test_cli_prefix_file_wins_over_prefix(tmp_path, monkeypatch)[source]ΒΆ
With both given, the file is the one the workflow means.
- tests.test_pr_body.test_cli_template_and_template_file_mutually_exclusive(tmp_path, monkeypatch)[source]ΒΆ
Passing both
--templateand--template-fileis rejected.
- tests.test_pr_body.test_cli_template_arg_invalid_format(tmp_path, monkeypatch)[source]ΒΆ
--template-argwithout=is rejected with a clear error.
- tests.test_pr_body.test_cli_template_arg_file_wins_over_template_arg(tmp_path, monkeypatch)[source]ΒΆ
A
--template-arg-filevalue is read stripped, and wins over the inline pair.
- tests.test_pr_body.test_cli_template_arg_file_invalid(tmp_path, monkeypatch, entry, message)[source]ΒΆ
A
--template-arg-filewithout=, or naming no file, is a usage error.