tests.test_docs_directives module¶
Every {click:run} block pins the outcome of the CLI it invokes.
The directive executes its body at build time through a bare exec(), so any
exception a block raises aborts sphinx-build. That makes the documentation
build a real gate, but only over the blocks that raise: a block asserting
nothing renders whatever the CLI printed, and a broken invocation prints a usage
error into the published page while the build stays green.
So the build cannot be the only check, and this test supplies the half it
misses: it reads the Markdown as text and requires each block to carry at least
one assertion. What that assertion pins is the author’s call. An exact
result.exit_code is the strongest form, and a containment check on
result.stdout still fails when the CLI errors instead of running.
The check runs on text alone: no build, no network, no platform floor. It parses
the fences through click_extra.markdown.blocks.fence_spans(), which
consumes a fence as an opaque unit, so a {click:run} example quoted inside a
longer code-block fence is never mistaken for a live directive.
- tests.test_docs_directives.run_blocks(path)[source]¶
Return each
{click:run}body inpath, as(line number, source).The leading
:option:lines the directive consumes are dropped, so the remainder parses as plain Python. Line numbers are 1-based, naming the opening fence.
- tests.test_docs_directives.test_markdown_files_are_collected()[source]¶
The glob feeding the check still finds the documentation.