livery.workshop._pytest_examples¶
livery.workshop._pytest_examples ¶
Run a package's documentation examples, the python files under docs/examples/.
An example is a file a page shows whole or by named section through
the snippets extension, so the code a reader sees and the code that
runs are one file. This plugin, loaded through the pytest11 entry
point, collects every docs/examples/**/*.py pytest is pointed at
as one test item per file, executed whole in a fresh module namespace
under its own path, so a failure's traceback names the example's file
and line. The python extension's examples runner, the function it
answers python.examples.runner with, points pytest at a package's
examples directory. A package's own setup around an example, a
registry capture or a recording mode, is its
docs/examples/conftest.py's business through the example
marker every item carries; the conftest itself is never an example.
Classes:
| Name | Description |
|---|---|
ExampleFile |
One example file: one item, the file run whole. |
Withheld |
An example as pytest's python collector sees it: nothing to collect. |
ExampleItem |
The run of one example file in a fresh module namespace. |
Functions:
| Name | Description |
|---|---|
pytest_configure |
Register the marker, so a strict-markers run accepts it. |
pytest_collect_file |
Collect an example file; every other file is another collector's. |
pytest_pycollect_makemodule |
Keep pytest's python collector off an example. |
Attributes:
| Name | Type | Description |
|---|---|---|
MARKER |
|
ExampleFile ¶
Withheld ¶
ExampleItem ¶
Bases: Item
The run of one example file in a fresh module namespace.
Methods:
| Name | Description |
|---|---|
runtest |
Execute the file under its own path; a raise is the failure, at its line. |
reportinfo |
The file, its first line, and the name the report prints. |
runtest ¶
Execute the file under its own path; a raise is the failure, at its line.
Source code in packages/workshop/src/livery/workshop/_pytest_examples.py
reportinfo ¶
The file, its first line, and the name the report prints.
pytest_configure ¶
Register the marker, so a strict-markers run accepts it.
Source code in packages/workshop/src/livery/workshop/_pytest_examples.py
pytest_collect_file ¶
pytest_collect_file(file_path: Path, parent: Collector) -> Collector | None
Collect an example file; every other file is another collector's.
Source code in packages/workshop/src/livery/workshop/_pytest_examples.py
pytest_pycollect_makemodule ¶
pytest_pycollect_makemodule(module_path: Path, parent: Collector) -> Collector | None
Keep pytest's python collector off an example.
Pytest collects a file named on its command line as a test module
whatever its name, and one whose name matches python_files in
a directory it walks. Either way it would import the example
outside the setup its conftest gives it, and run the example's
test_* functions as tests of the workspace: a function showing
a reader how to test a tasks file then runs the workspace's own
gate from inside it. The example stays this plugin's, run whole.