Skip to main content

A pytest plugin that generates documentation of the testing application itself.

PyPI version Python versions Travis CI Black Pepy.tech https://codecov.io/gh/liiight/pytest_docs/branch/master/graph/badge.svg

Features

Create documentation of your tests. Turns this:

'''This is the module doc'''
import pytest

pytestmark = [
    pytest.mark.module_mark,
    pytest.mark.module_mark_2,
    pytest.mark.pytest_doc(name="Test Docs"),
]


@pytest.mark.class_marker
@pytest.mark.pytest_doc(name="Test Class")
class TestClass:
    '''This is the class doc'''

    @pytest.mark.func_mark_a("foo")
    def test_func_a(self):
        '''This is the doc for test_func_a'''
        assert 1

    @pytest.mark.kwarg_mark(goo="bla")
    def test_func_b(self):
        '''This is the doc for test_func_b'''
        assert 1

To this:

# Test Docs
This is the module doc

**Markers:**
- module_mark
- module_mark_2
- pytest_doc  (name=Test Docs)
## Test Class
This is the class doc

**Markers:**
- pytest_doc  (name=Test Class)
- class_marker
### test_func_a
This is the doc for test_func_a

**Markers:**
- func_mark_a (foo)
### test_func_b
This is the doc for test_func_b

**Markers:**
- kwarg_mark  (goo=bla)

Current supported formats:

  • Markdown

  • reStrcutured text

Why not sphinx?

(More accurately, why not sphinx-autodoc?) Sphinx is an amazing tool that I use and used in other project. To use its autodoc plugin, it need the documented plugin to be importable by the python interperter. Pytest test collection and invocation uses a completely separate mechanism. If you believe that it somehow possible to use sphinx to create pytest documentation, please do not hesitate to contact me.

Requirements

  • Python 3.4, 3.5, 3.6 or 3.7

  • Pytest >= 3.5.0

Installation

You can install “pytest-docs” via pip from PyPI:

$ pip install pytest-docs

Usage

Use --docs [PATH] to create the documentation.

Use --doc-type to select the type (currently supports md and rst)

Use @pytest.mark.pytest_doc(name="Test Class") to override name of element. It’ll override name based on the place it is being used (module, class or function).

Note: pytest-docs uses the pytest collection mechanism, so your documentation will be generated according the the usual collection commands used to run the tests.

What’s planned ahead

  1. See if anyone is even interested in this

  2. Document fixtures

  3. Document tests and fixtures parametrization

  4. Custom formatters via hooks

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-docs” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Release files for pytest-docs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-docs 0.1.0
File Size Uploaded
pytest-docs-0.1.0.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-docs 0.1.0
File Interpreter ABI Platform
pytest_docs-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / pytest-docs-0.1.0.tar.gz

Download URL pytest-docs-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0ffa61dafd3aca81bb8e64416207b599e5906fde2d6ad68e430975196eb397e0
BLAKE2b-256 checksum
How to use checksums
e2f1c84145ca5d0718cd674cea9fe38a21d04620676b0592b81b2c41837c51d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / pytest_docs-0.1.0-py3-none-any.whl

Download URL pytest_docs-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7c37770dbc3e3279695639e5f73e21657c515b70c4c0d749745a397c5c599f5
BLAKE2b-256 checksum
How to use checksums
b804d05a9d87648e7178309a49a0e2328bd7bfa3ed430faa6bfc59396d8f74d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page