$npx skillfedfor your agent

pytest-markdown-docs

Run markdown code fences through pytest

Worth itPyPI TestingReleased Mar 2026300.3K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_markdown_docs-0.9.2-py3-none-any.whl
v0.9.2 · released 2026-03-23 · Python >=3.9 · 2 runtime deps: markdown-it-py, pytest

Yes. The plugin solves a real problem—keeping documentation examples in sync with code—with low friction and active maintenance. MIT licensing removes legal concerns. It integrates cleanly into existing pytest workflows via a command-line flag. Suitable for projects that prioritize documentation quality and want automated validation of code examples.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.9 or later; pytest must be installed as a runtime dependency.
  • Low install friction with only two runtime dependencies (pytest and markdown-it-py).
  • Active maintenance with a recent release on 2026-03-23 and last commit on 2026-06-11.

License · maintenance · safety

MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

last release 2026-03-23 (144 days) · last repo commit 2026-06-11 · 85 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 300,279 downloads/mo, #7,843 on PyPI

Verify before relying

pip install pytest-markdown-docs

# In a markdown file or docstring:
# ```python
# import mymodule
# result = mymodule.Foo().bar()
# assert result == "hello"
# ```

pytest --markdown-docs
  • Whether line number reporting in tracebacks is sufficiently accurate for debugging docstring-inlined tests.
  • Performance impact when running against large markdown files or many code snippets.
  • Compatibility with pytest plugins that also modify test discovery or execution.
Same gist for agents: .md · .json

What it is and what it does

pytest-markdown-docs is a pytest plugin that treats Python code blocks in markdown files and docstrings as executable test cases. It scans for fenced code blocks (triple backticks) marked with python, python3, or py language tags, and runs them through pytest's test framework. This bridges the gap between documentation and testing: code examples in your README, API docs, or docstrings can be automatically validated to ensure they remain correct as your codebase evolves.

The plugin supports several advanced features: skipping blocks with notest markers, injecting global variables or fixtures into code blocks, using pytest fixtures (including async fixtures from pytest-asyncio), chaining snippets with continuation markers to maintain state across blocks, and retrying flaky tests. It also handles MDX files with metadata comments and supports custom markdown-it-py parser configurations for compatibility with tools like Material for MkDocs.

Use it for

  • Validate code examples in README files and API documentation to prevent outdated or broken examples.
  • Test docstring examples in library code without duplicating assertions in separate test files.
  • Ensure tutorial markdown files contain working, up-to-date code snippets that readers can trust.
  • Catch regressions in documented usage patterns when refactoring library APIs.
  • Generate living documentation where code examples are guaranteed to execute correctly.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

The plugin solves a real problem—keeping documentation examples in sync with code—with low friction and active maintenance. MIT licensing removes legal concerns. It integrates cleanly into existing pytest workflows via a command-line flag. Suitable for projects that prioritize documentation quality and want automated validation of code examples.

Install

pytest-markdown-docs on PyPI

Before you install

Low install friction with only two runtime dependencies (pytest and markdown-it-py). Active maintenance with a recent release on 2026-03-23 and last commit on 2026-06-11.

Requires Python 3.9 or later; pytest must be installed as a runtime dependency.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

pip install pytest-markdown-docs

# In a markdown file or docstring:
# ```python
# import mymodule
# result = mymodule.Foo().bar()
# assert result == "hello"
# ```

pytest --markdown-docs

Verify before relying

  • Whether line number reporting in tracebacks is sufficiently accurate for debugging docstring-inlined tests.
  • Performance impact when running against large markdown files or many code snippets.
  • Compatibility with pytest plugins that also modify test discovery or execution.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.9
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
markdown-it-pypytest
MaintenanceActively maintained 144 days since the last release
Last repo commit
First released
Downloads300,279 / month, #7,843 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14

Evidence: pytest_markdown_docs-0.9.2-py3-none-any.whl

Tags

Capabilities
markdown code snippet testingpytest markdown plugindocstring code examples as testsmarkdown documentation testingexecutable code fence validationpytest doctest alternativemarkdown code block runner
Topics
documentation-testingpytest-pluginexample-validation

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “markdown documentation testing”

  • pytest-markdown-docsA pytest plugin that executes Python code snippets embedded in…
  • pytest-codeblocksA pytest plugin that automatically discovers and runs Python and…
  • sybil-extrasProvides specialized evaluators and parsers that extend Sybil, a…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also markdown-exec · pytest-codeblocks · pytest-describe · lib-detect-testenv · doccmd · sybil · pytest-md · pytest-examples · pytest-doctestplus · sybil-extras