A pytest plugin to doctest your markdown files
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-markdoctest-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-markdoctest-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05c2eefcd35876a2b93fcbfb7c6d3d68fa30a4ac61e0d51cb03e82251dd96764 |
|
MD5 | e9cd5c62853032e02e0649daf1bd0c21 |
|
BLAKE2b-256 | 742762f1ccac6edf4bab2eb2cfd3968ccf58ff3e1bbaeef10cecc99ffecba295 |
File details
Details for the file pytest_markdoctest-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_markdoctest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d93905272727def12b9d19119eee14d9f603a7b9d2f4c9e7d27fd3bcc4d287 |
|
MD5 | d2bee856f4313fdce4bed9d577f0b7c7 |
|
BLAKE2b-256 | d1bf365f97402063a6c635a37f848199a3d3ce18aad27eb870a309f709640cde |