tests.test_awesome_toc module

Tests for the removal of the ToC entries awesome-lint forbids.

tests.test_awesome_toc.ENGLISH_SECTIONS = ('Contents', 'Mango', 'Papaya', 'Lychee', 'Contributing', 'Footnotes')

Section titles of the reference readme, in document order.

tests.test_awesome_toc.FRENCH_SECTIONS = ('Sommaire', 'Mangue', 'Papaye', 'Litchi', 'Contribuer', 'Notes')

The same sections, translated. Only positions tie one list to the other.

Contribuer is why [tool.typos] default.extend-words carries an entry for it: this is the token’s only occurrence, and without the entry the unattended fix-typos job proposes “correcting” the French to English. Do not prune the allowlist entry while this fixture stands.

tests.test_awesome_toc.render_readme(sections)[source]

Render a readme whose ToC lists every section, as mdformat-toc leaves it.

Return type:

str

tests.test_awesome_toc.toc_entries(content)[source]

List the link texts of a readme’s ToC block.

Return type:

list[str]

tests.test_awesome_toc.test_readme_re(filename, matches)[source]

Only a root readme and its translations are rewritten.

tests.test_awesome_toc.test_headings_skips_fenced_code()[source]

A # line inside a code fence is a comment, not a heading.

tests.test_awesome_toc.test_strip_toc_entries_leaves_the_rest_of_the_document_alone()[source]

A list item outside the ToC block is not a ToC entry.

tests.test_awesome_toc.test_strip_toc_entries_without_a_toc_block()[source]

A readme carrying no ToC marker is returned untouched.

tests.test_awesome_toc.test_forbidden_headings_for_maps_positions_onto_a_translation()[source]

A translated section is forbidden when its English peer is.

tests.test_awesome_toc.test_forbidden_headings_for_falls_back_on_a_count_mismatch(caplog)[source]

A translation that dropped a section is matched on English names only.

tests.test_awesome_toc.test_fix_awesome_toc_strips_reference_and_translation(tmp_path)[source]

The reported bug: a translated ToC keeps the entries the English one loses.

tests.test_awesome_toc.test_fix_awesome_toc_matches_an_untranslated_section_by_name(tmp_path)[source]

A section left in English is still caught, positions or not.

tests.test_awesome_toc.test_fix_awesome_toc_is_idempotent(tmp_path)[source]

Re-running finds nothing left to remove.

tests.test_awesome_toc.test_fix_awesome_toc_without_a_reference_readme(tmp_path, caplog)[source]

A translation alone still loses the entries awesome-lint names.

tests.test_awesome_toc.test_fix_awesome_toc_rewrites_the_reference_first(tmp_path)[source]

The reference is processed before any translation is compared to it.