tests.test_broken_links moduleΒΆ
Tests for the broken links report: linkcheck parsing and the issue verdict.
- tests.test_broken_links.test_get_label(repo, expected)[source]ΒΆ
Only a repo whose name starts with
awesome-gets the fix-link label.
- tests.test_broken_links.test_parse_output_json_empty_file(tmp_path)[source]ΒΆ
Empty file returns no results.
- tests.test_broken_links.test_parse_output_json_skips_blank_lines(tmp_path)[source]ΒΆ
Blank lines in the file are skipped.
- tests.test_broken_links.test_parse_output_json_single_entry(tmp_path)[source]ΒΆ
Single entry is parsed correctly.
- tests.test_broken_links.test_parse_output_json_multiple_entries(tmp_path)[source]ΒΆ
Multiple entries are parsed correctly.
- tests.test_broken_links.test_parse_output_json_missing_info_field(tmp_path)[source]ΒΆ
Missing info field defaults to empty string.
- tests.test_broken_links.test_filter_by_status(status, expected_count)[source]ΒΆ
Only broken and timeout statuses are kept.
- tests.test_broken_links.test_filter_broken_mixed_statuses()[source]ΒΆ
Only broken and timeout are kept from a mixed list.
- tests.test_broken_links.test_report_single_broken_link()[source]ΒΆ
Single broken link generates a valid report.
- tests.test_broken_links.test_report_groups_by_file_alphabetically()[source]ΒΆ
Results are grouped by filename in alphabetical order.
- tests.test_broken_links.test_report_escapes_pipe_chars_in_info()[source]ΒΆ
Pipe characters in info are escaped to avoid breaking tables.
- tests.test_broken_links.test_report_source_url_links_filenames_and_lines()[source]ΒΆ
When source_url is provided, filenames and line numbers are linked.
- tests.test_broken_links.test_report_no_source_url_plain_text()[source]ΒΆ
Without source_url, filenames and line numbers are plain text.
- tests.test_broken_links.test_report_leaves_external_content_unsanitized(info)[source]ΒΆ
The report renderer passes tool output through; the caller sanitizes it.
Splitting the two is what lets the same report be written to a file, where the mention would be inert, or posted to an issue, where it would not.
test_lychee_output_sanitizedcovers the callerβs half.
- tests.test_broken_links.test_lychee_output_sanitized(tmp_path)[source]ΒΆ
Lychee markdown output is sanitized before embedding in issue body.
- tests.test_broken_links.test_lychee_section_reads_the_exit_code(exit_code, has_report, verdict, needle)[source]ΒΆ
Only exit 2 with a report reports broken links; 1 and 3 report nothing.
- tests.test_broken_links.test_sphinx_section_reads_the_statuses(tmp_path, status, verdict)[source]ΒΆ
Any broken or timed-out link makes the Sphinx verdict broken.
- tests.test_broken_links.test_sphinx_section_warns_of_one_location_per_url(tmp_path, status, warns)[source]ΒΆ
Only a section with broken links warns that it lists a URL at one location.
Sphinx linkcheck checks a URL once, so a URL used in two files shows under one of them: the warning sends the reader to search for the other.
- tests.test_broken_links.test_a_failed_lychee_run_leaves_the_issue_alone(tmp_path, monkeypatch, exit_code)[source]ΒΆ
A run that did not complete never closes an open broken links issue.
It says nothing about the links, so claiming βNo more issues.β would close a report of links that may still be broken.
- tests.test_broken_links.test_a_failed_lychee_run_beside_broken_sphinx_links_files_both(tmp_path, monkeypatch)[source]ΒΆ
Broken links found anywhere are filed, with the incomplete run said so.
- tests.test_broken_links.test_a_completed_run_files_or_closes_the_issue(tmp_path, monkeypatch, exit_code, has_issues)[source]ΒΆ
A completed run decides the issue, either way.
- tests.test_broken_links.test_a_ci_run_detects_every_default(tmp_path, monkeypatch)[source]ΒΆ
In CI, the name, the linkcheck output and its source URL are all detected.
- tests.test_broken_links.test_no_repository_name_to_detect_is_an_error(tmp_path, monkeypatch)[source]ΒΆ
With neither
$GITHUB_REPOSITORYnor a clone, no name selects the label.
- tests.test_broken_links.test_no_checker_leaves_the_issue_alone(tmp_path, monkeypatch, caplog)[source]ΒΆ
With no checker run, nothing is known about the links: the issue stays.
No crawl and no Sphinx linkcheck output said a word about the links, so closing an open issue would announce fixes that nobody checked.
- tests.test_broken_links.test_cli_with_no_checker_exits_clean(tmp_path, monkeypatch)[source]ΒΆ
--no-lycheewith no linkcheck output leaves the issue, and exits 0.The job is advisory: a run that checked nothing must not turn it red.
- tests.test_broken_links.test_cli_without_a_repository_name_is_a_usage_error(tmp_path, monkeypatch)[source]ΒΆ
No
--repo-nameand nothing to detect one from fails before any check.
- tests.test_broken_links.test_run_lychee_skips_a_repository_with_no_documentation(tmp_path, monkeypatch)[source]ΒΆ
With no documentation file, lychee has nothing to check and never runs.
- tests.test_broken_links.test_run_lychee_reads_back_the_report_it_asked_for(tmp_path, monkeypatch)[source]ΒΆ
The crawl is the bare
run lycheeinvocation, plus the report flags.The report reaches the issue through the run itself, with no path agreed on with a workflow step.
- tests.test_broken_links.test_run_lychee_without_a_report_says_so(tmp_path, monkeypatch)[source]ΒΆ
A crawl that wrote no report carries none, whatever its exit code.
- tests.test_broken_links.test_run_lychee_that_cannot_install_did_not_complete(tmp_path, monkeypatch)[source]ΒΆ
A lychee that cannot be installed checked nothing: the issue stays put.
- tests.test_broken_links.FIG_TEMPLATE = 'templates/fig.md'ΒΆ
A documentation file that the configurations below exclude.
- tests.test_broken_links.test_run_lychee_leaves_out_the_paths_lychee_excludes(tmp_path, monkeypatch, config, checked)[source]ΒΆ
lychee warns on each input that its
exclude_pathexcludes: none gets there.lychee searches each expression in an input path as it was passed, which is the string the inventory hands over.
- tests.test_broken_links.test_run_lychee_skips_when_lychee_excludes_every_file(tmp_path, monkeypatch)[source]ΒΆ
With every documentation file excluded, lychee has nothing to check.
- tests.test_broken_links.test_lychee_github_auth_needs_a_token(tmp_path, monkeypatch, token)[source]ΒΆ
With no token, the crawl stays anonymous and no file is written.
- tests.test_broken_links.test_lychee_github_auth_keeps_the_project_config(tmp_path, monkeypatch, files, project_config)[source]ΒΆ
Name the config lychee would find, then the file that signs github.com.
Any
--configstops lychee from finding the projectβs own config, so the arguments name that file first. The token is in the file, never in them.
- tests.test_broken_links.test_release_download_pattern(url, excluded)[source]ΒΆ
A signed crawl skips the release downloads only.
- tests.test_broken_links.test_blob_url_remap(url, remapped)[source]ΒΆ
A
/blob/URL becomes the raw URL of its file, query and fragment dropped.Read with Pythonβs
re, translating the${N}references of the Rustregexcrate: the pattern itself uses only syntax both engines share.
- tests.test_broken_links.test_run_lychee_signs_github_requests(tmp_path, monkeypatch)[source]ΒΆ
With a token, the crawl reads it from a file that ends with the crawl.
- tests.test_broken_links.test_signed_crawl_keeps_the_project_excludes(tmp_path, monkeypatch, capfd)[source]ΒΆ
The pinned lychee applies the excludes of both config files, and the remap.
Lists the links lychee would check: the
[tool.lychee]exclude and the release download exclude both apply, and the/blob/link shows as the raw.githubusercontent.com URL lychee checks in its place. Markedonce: it downloads the pinned lychee binary, so one runner suffices.