sybil
Automated testing for the examples in your code and documentation.
What it is and what it does
Sybil is a testing library that extracts code examples from your documentation and source files, then runs them as part of your test suite. Instead of manually keeping examples in sync with your code, Sybil parses them directly from their source (reStructuredText, Markdown, or other formats) and validates that they execute correctly. This catches documentation rot early—when an API changes, the tests fail immediately if examples become outdated.
The library integrates with standard Python test runners, so examples run alongside your unit tests with no special setup. It has no external runtime dependencies, making it lightweight to add to any project. It's designed for developers who want their documentation to be a reliable, executable specification rather than prose that drifts out of sync with the code.
Use it for:
- Validate code snippets in API documentation to ensure they remain correct as the codebase evolves
- Test example scripts embedded in README or tutorial files as part of CI/CD
- Verify that code samples in docstrings and reStructuredText files actually run without errors
- Catch breaking changes early by running documented examples in your test suite
- Maintain a single source of truth for examples instead of duplicating them in tests and docs
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Sybil parses and executes code examples embedded in your source code and documentation as part of your normal test suite, validating that documented examples actually work.
Yes. Sybil fills a real gap: keeping documentation examples in sync with code. It has no dependencies, low install friction, active maintenance, a permissive license, and solves a concrete problem that affects most projects with substantial documentation. The only reason not to install is if you have no documented examples to validate.
Install
sybil on PyPI
pip
pip install sybiluv
uv add sybilpoetry
poetry add sybilInstalling sybil
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 62 days ago with recent commits. Requires Python 3.11 or later.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install sybil
from sybil import Sybil
from sybil.parsers.rest import CodeBlockParser
examples = Sybil([CodeBlockParser()], pattern='*.rst')
Requires Python 3.11 or later.
Verify before relying
- Whether Sybil supports all major test runners (pytest, unittest, nose) or only a subset
- Whether it can extract examples from formats beyond reStructuredText and Markdown
- Performance characteristics when running large numbers of examples
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 62 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 572,260/month — #5,946 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sybil-10.1.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
sybil-extrasProvides specialized evaluators and parsers…
permissive · top 15,000 on PyPI
pytest-markdown-docsA pytest plugin that executes Python code…
permissive · top 15,000 on PyPI
math-verifyEvaluates mathematical expressions from LLM…
permissive · top 5,000 on PyPI
xdoctestXdoctest finds and executes test code embedded…
permissive · top 5,000 on PyPI
markdown-execExecutes code blocks embedded in Markdown files…
permissive · top 5,000 on PyPI
rstcheck-coreValidates reStructuredText syntax and checks…
permissive · top 5,000 on PyPI
cogappCog executes Python code snippets embedded in…
permissive · top 15,000 on PyPI
strictyamlStrictYAML parses and validates YAML documents…
permissive · top 1,000 on PyPI
pytest-examplesA pytest plugin that finds, lints, runs, and…
permissive · top 15,000 on PyPI
codeownersParses GitHub CODEOWNERS files to extract…
permissive · top 5,000 on PyPI