tests.mkdocs package¶
Submodules¶
tests.mkdocs.conftest module¶
Fixtures and helpers for MkDocs tests.
Separated from the root tests/conftest.py so that the MkDocs dependency
(and mkdocs-click, pymdown-extensions) is only imported when running
the tests in this subdirectory. Downstream packagers can skip these tests
with --ignore=tests/mkdocs without affecting the rest of the test suite.
tests.mkdocs.test_mkdocs module¶
Tests for the MkDocs ANSI color plugin.
- tests.mkdocs.test_mkdocs.test_mkdocs_entry_point()[source]¶
Verify the
mkdocs.pluginsentry point is declared inpyproject.toml.
- tests.mkdocs.test_mkdocs.test_on_config_patches_formatters()[source]¶
After
on_config, both formatter classes inherit fromAnsiHtmlFormatter.
- tests.mkdocs.test_mkdocs.test_on_config_idempotent()[source]¶
Calling
on_configtwice does not create a new class each time.
- tests.mkdocs.test_mkdocs.test_patched_formatter_preserves_pymdownx_mro()[source]¶
The patched formatters still inherit from the original pymdownx classes.
- tests.mkdocs.test_mkdocs.test_patched_formatter_renders_ansi()[source]¶
The patched block formatter decomposes compound ANSI tokens into CSS classes.
- tests.mkdocs.test_mkdocs.test_ansi_stylesheet_only_contains_ansi_rules()[source]¶
The generated stylesheet colors the
-Ansi-*classes and nothing else.Standard Pygments token rules must stay out: dumping the full style would override the themeās own syntax-highlighting colors for every code block.
- tests.mkdocs.test_mkdocs.test_on_config_registers_stylesheet()[source]¶
on_configappends the ANSI stylesheet toextra_cssexactly once.
- tests.mkdocs.test_mkdocs.test_on_post_build_writes_stylesheet(tmp_path)[source]¶
on_post_buildwrites the ANSI stylesheet under the site directory.
- tests.mkdocs.test_mkdocs.test_patch_mkdocs_click_usage()[source]¶
After patching,
_make_usageyieldsansi-outputfences.
- tests.mkdocs.test_mkdocs.test_patch_mkdocs_click_plain_options()[source]¶
After patching,
_make_plain_optionsyieldsansi-outputfences.
- tests.mkdocs.test_mkdocs.test_patch_mkdocs_click_idempotent()[source]¶
Calling
_patch_mkdocs_clicktwice does not double-wrap.
- tests.mkdocs.test_mkdocs.test_patch_mkdocs_click_forces_color_during_capture(monkeypatch)[source]¶
The patched generators capture help with color forced, even under
NO_COLOR.Swapping the lexer to
ansi-outputis pointless if the captured help carries no escape codes, which is exactly what happens when the buildās stdout is a pipe. The wrapper must therefore materialize the help while the color override is active. Spying onmake_formatter(where Rich and Click read the environment to decide on color) provesFORCE_COLORis set and the disabling vars are cleared at capture time, and that the surrounding environment is restored once the capture completes.
- tests.mkdocs.test_mkdocs.test_on_config_patches_mkdocs_click()[source]¶
on_configpatches mkdocs-click alongside pymdownx.highlight.
- tests.mkdocs.test_mkdocs.test_full_build_renders_ansi_colors(tmp_path)[source]¶
An end-to-end MkDocs build strips escape codes and ships the color stylesheet.
This exercises the whole plugin wiring (formatter patch plus stylesheet injection) the way bump-my-versionās site does: an
ansi-outputblock goes in, and class-decorated spans backed by a linked stylesheet come out, with no raw escape codes left behind.