pytest-markdoctest
A pytest plugin to doctest your markdown files.
Help you test your python blocks in markdown in doctest style, and make sure them behaving as you expected. This is especially helpful when dealing with markdown files containing many demo code, such as
- A project documented in markdown files,
- A tutorial on python written in markdown.
Requirements
- python>=3.7
- pytest>=6
Installation
You can install "pytest-markdoctest" via pip from PyPI:
$ pip install pytest-markdoctest
Usage
To test a single markdown file:
$ pytest docs/index.md
or test all markdown files in a directory:
$ pytest docs/
Your markdown file may contains REPL block (Read-Eval-Print-Loop).
>>> 2 + 3
5
>>> print("Hello World!")
Hello World!
Or script block.
import math
def square(x):
return x*x
Variables/functions defined before are accessible in subsequent blocks.
>>> math.pow(2, 2)
4.0
>>> square(2)
4
Markdoctest automatically find all code blocks tagged by python, py, pycon and test them.
Directives are allowed to control testing behavior.
<!-- doctest: +SKIP -->
```python
import math
a = 3 / 0
```
Advanced Usage
License
Distributed under the terms of the MIT license, "pytest-markdoctest" is free and open source software
Acknowledgement
This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.
Release files for pytest-markdoctest 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-markdoctest-0.1.0.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_markdoctest-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / pytest-markdoctest-0.1.0.tar.gz
| Download URL | pytest-markdoctest-0.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05c2eefcd35876a2b93fcbfb7c6d3d68fa30a4ac61e0d51cb03e82251dd96764
|
|
BLAKE2b-256 checksum How to use checksums |
742762f1ccac6edf4bab2eb2cfd3968ccf58ff3e1bbaeef10cecc99ffecba295
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Release files / pytest_markdoctest-0.1.0-py3-none-any.whl
| Download URL | pytest_markdoctest-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24d93905272727def12b9d19119eee14d9f603a7b9d2f4c9e7d27fd3bcc4d287
|
|
BLAKE2b-256 checksum How to use checksums |
d1bf365f97402063a6c635a37f848199a3d3ce18aad27eb870a309f709640cde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|