Skip to main content

Pytest plugin for runs tests directly from Markdown files

Project description

markdown-pytest

Pytest plugin for running tests directly from Markdown files.

Markdown:

<!--- name: test_assert_true -->
```python
assert True
```
Will be shown as
assert True

Code split

You can split test to the multiple blocks with the same test name:

Markdown:

This block performs import:

<!--- name: test_example -->
```python
from itertools import chain
```

`chain` usage example:

<!--- name: test_example -->
```python
assert list(chain(range(2), range(2))) == [0, 1, 0, 1]
```
Will be shown as

This block performs import:

from itertools import chain

chain usage example:

assert list(chain(range(2), range(2))) == [0, 1, 0, 1]

Fictional Code Examples

Code without &#60;!--- name: test_name --&#62; comment will not be executed.

```python
from universe import antigravity, WrongPlanet

try:
    antigravity()
except WrongPlanet:
    print("You are on the wrong planet.")
    exit(1)
```
Will be shown as
from universe import antigravity, WrongPlanet

try:
    antigravity()
except WrongPlanet:
    print("You are on the wrong planet.")
    exit(1)

Usage example

This README.md file might be tested like this:

$ pytest -v README.md
======================= test session starts =======================
platform darwin -- Python 3.10.2, pytest-7.2.0, pluggy-1.0.0
plugins: markdown-pytest-0.1.0
collected 2 items

README.md::test_assert_true PASSED                                                                                                                                                                                                     [ 50%]
README.md::test_example PASSED

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

markdown_pytest-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

markdown_pytest-0.2.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file markdown_pytest-0.2.0.tar.gz.

File metadata

  • Download URL: markdown_pytest-0.2.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.0 Darwin/22.2.0

File hashes

Hashes for markdown_pytest-0.2.0.tar.gz
Algorithm Hash digest
SHA256 710814ba5ab020c524aedab43b4baecdfd1a3c099940004ad138e331bbad920d
MD5 317aec27d49c9c280303b0644098dff1
BLAKE2b-256 3d90aa69783f45366e1408f150eb089d1bc9b7aece6808b54e3d32447c9a01ec

See more details on using hashes here.

File details

Details for the file markdown_pytest-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: markdown_pytest-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.0 Darwin/22.2.0

File hashes

Hashes for markdown_pytest-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90d794f6e509009a19c28e2d18f75ff3afbfc2ca3551c5376fe9cb0b7cebd623
MD5 47a534ba4e3444fd8147f2d24e70ce13
BLAKE2b-256 21d7dff902108f642bad29bcdd158309dacbe8239c55f794c944d30927a3b89c

See more details on using hashes here.

Supported by

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