Pytest plugin that executes README code examples.
Project description
Overview
swarmauri_tests_readme_examples is a pytest plugin that
turns Markdown code blocks into executable tests. It scans README (or other
documentation) files for Python examples and verifies that every runnable block
still executes successfully. This keeps documentation trustworthy without
hand-maintained test_readme_example.py scaffolding.
The plugin works out of the box for Python code blocks (```python, ```py,
```pycon) and exposes command-line flags and pyproject.toml settings so you can
fine-tune which files and languages are exercised.
Installation
pip install swarmauri_tests_readme_examples
pytest discovers the plugin automatically after installation.
Quick Start
Run pytest as usual to execute every Python code block in README.md:
pytest
Sample failure output:
E README.md::block-3 raised ValueError('boom')
Configuration
You can control the scan through CLI options or pyproject.toml:
--readme-files– comma/newline separated Markdown files (default:README.md)--readme-languages– languages to execute (default:python,py,pycon)--readme-mode–parameterized(default) oraggregate--readme-skip-markers– comment markers that skip a block when they appear on the first non-empty line
pyproject.toml example (under [tool.pytest.ini_options]):
[tool.pytest.ini_options]
readme_files = """
README.md
docs/guide.md
"""
readme_languages = """
python
py
"""
readme_mode = "aggregate"
readme_skip_markers = """
# pytest: skip-example
# docs: skip
"""
Skipping Blocks
Place one of the configured skip markers on the first non-empty line to leave a code block out of execution:
```python
# pytest: skip-example
print("shown in docs, ignored in tests")
```
Aggregate Mode
Switch to --readme-mode=aggregate (or set readme_mode = "aggregate") to
collapse all README checks into a single pytest item that aggregates every
failure message. This is handy when you want a brief summary rather than many
individual tests.
License
Licensed under the Apache 2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_tests_readme_examples-0.1.0.tar.gz.
File metadata
- Download URL: swarmauri_tests_readme_examples-0.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a5c6fb74213d3b23a38cb8290319d81870c434b53e366a9828e65f7de2e8204
|
|
| MD5 |
03702f8c86fdf34f8289c165ae59fc7e
|
|
| BLAKE2b-256 |
3d9871d237d384572d90df9ba5c22991b6e49b89e5b189fffe6b22ec6185c6b4
|
File details
Details for the file swarmauri_tests_readme_examples-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tests_readme_examples-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
156c0f8c16b13aea0acab7351469911ba62871c3d4a31aa903892cd4808011c0
|
|
| MD5 |
d2d08c7487f0284b5a77095c7708d8a6
|
|
| BLAKE2b-256 |
327f0a52f481b47b36825e354452cbbc16b400f4af295ddda4a3eef0327f0e7b
|