Skip to main content

Pytest plugin that renders readable test specifications and exports documentation

Project description

pytest-readable

PyPI Python License

pytest-readable is a pytest plugin that turns tests into human-readable specifications and exports them to Markdown or CSV.

It is useful when you want pytest output to be easier to review, easier to share with non-developers, and easier to reuse as lightweight test documentation.

Installation

pip install pytest-readable

Requirements

  • Python 3.10+
  • pytest 9.x

Quick Example

Test:

from pytest_readable import readable


@readable(
    intention="User login succeeds with valid credentials",
    steps=[
        "Create a user",
        "Attempt login with the correct password",
    ],
    criteria=[
        "Login succeeds",
        "A session token is returned",
    ],
)
def test_user_login():
    ...

Run:

pytest --readable-detailed

Output:

Readable summary

- Total: 1
- collected: 1

Detailed list

- [unknown] tests/test_auth.py::test_user_login
    What it tests: User login succeeds with valid credentials
    Steps:
      1. Create a user
      2. Attempt login with the correct password
    Pass conditions:
      1. Login succeeds
      2. A session token is returned

Final summary: total=1, passed=0, failed=0, skipped=0

Common Commands

Readable terminal summary:

pytest --readable

This prints a summarized readable report without pytest's native header or footer noise.

Readable detailed report:

pytest --readable-detailed

Detailed aliases:

pytest --readable --detailed
pytest --readable -d

Readable verbose report:

pytest --readable-verbose

Verbose aliases:

pytest --readable --verbose
pytest --readable -v

Export Markdown documentation:

pytest --readable --export=markdown

Export CSV documentation:

pytest --readable --export=csv

Set a custom output path:

pytest --readable --export=markdown --readable-out=docs/tests-readable.md

When to use pytest-readable

Use pytest-readable when you want to:

  • make pytest output easier to read
  • export test documentation to Markdown or CSV
  • review test intent without reading raw test code
  • share tests with QA, analysts, or non-developers
  • keep tests and lightweight documentation aligned
  • present test coverage in a more human-friendly format

Who it is for

pytest-readable is especially useful for:

  • solo developers
  • small teams
  • internal tools
  • lightweight QA workflows
  • multilingual teams that want readable test output
  • projects where tests also serve as living documentation

Why use it instead of plain pytest output?

Plain pytest output is optimized for test execution and debugging.

pytest-readable is optimized for:

  • readable review
  • explicit test intent
  • lightweight documentation export
  • sharing tests with people who do not want to read raw test code

Design Philosophy

pytest-readable is intentionally non-inferential.

The plugin does not attempt to interpret test code, infer behavior, or generate missing semantics. It renders only the metadata that the author explicitly declares.

This keeps the plugin:

  • deterministic
  • framework-agnostic
  • compatible with both human-written and AI-generated tests

pytest-readable does not try to make tests better. It makes explicitly described tests more readable.

Scope

This project focuses on:

  • readable test intention
  • explicit steps
  • explicit pass conditions
  • pytest-aware rendering
  • Markdown and CSV export

It does not aim to become:

  • a TDD framework
  • a test generator
  • an AI interpreter
  • a writable test authoring tool

CLI Helper

The package also installs a small readable helper command that forwards to pytest with readable defaults:

readable pytest tests/

Equivalent pytest invocation:

pytest --readable --color=yes tests/

Detailed readable output:

readable --detailed pytest tests/
readable pytest --detailed tests/
readable pytest -d tests/

Verbose readable output:

readable pytest -v tests/
readable pytest --verbose tests/

Mode equivalences:

readable pytest               -> pytest --readable
readable pytest -d           -> pytest --readable -d
readable pytest --detailed   -> pytest --readable --detailed
readable pytest -v           -> pytest --readable -v
readable pytest --verbose    -> pytest --readable --verbose

Note: -d works as a readable shorthand when used together with --readable, even though pytest --help lists the long-form detailed options.

Helper-specific commands:

readable --help
readable --find-missing
readable --find-missing --tests-root=tests

Decorator Metadata

Document tests with explicit metadata:

from pytest_readable import readable


@readable(
    intention="Search returns matching results",
    steps=[
        "User enters a search query",
        "The system queries the search index",
    ],
    criteria=[
        "The response status is 200",
        "The results contain matching items",
    ],
)
def test_search():
    ...

The preferred metadata shape is:

@readable(
    intention="What the test validates",
    steps=["Action performed"],
    criteria=["Expected observable outcome"],
)

Language Support

Supported output languages:

  • English
  • Spanish

Example:

pytest --readable-lang=es

Contributing

See CONTRIBUTING.md for contribution guidelines.

Changelog

See CHANGELOG.md for release history.

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_readable-0.1.1.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_readable-0.1.1-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_readable-0.1.1.tar.gz.

File metadata

  • Download URL: pytest_readable-0.1.1.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pytest_readable-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1a99822f74830efca9f8bfa28d34e44dcc08dc0cb6506456590445af0ab01823
MD5 03b570cd7e2ff0c122d63a52485de53e
BLAKE2b-256 9f9a0f5067ed56fdc4b65c47886a6c91f7dcefe71fe66556882a46ef743d2cf2

See more details on using hashes here.

File details

Details for the file pytest_readable-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_readable-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94f46ae3d392b770113beebce729830b1d66dfc13afc80bf466a4038a820c40b
MD5 1d79b7f5438ff7ca1444c52a9b3d9ddf
BLAKE2b-256 b1f5ac8ceb002fe57380fb7cd25a564291425718f9a0e0ee5c26a3fd88b36040

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page