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

This module parsed code by these rules:

  • Code without <!-- name: test_name --> comment will not be executed.
  • Allowed two or three dashes in the comment symbols
  • Code blocks with same names will be merged in one code and executed once

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 <!-- name: test_name --> 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.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

markdown_pytest-0.2.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: markdown_pytest-0.2.1.tar.gz
  • Upload date:
  • Size: 7.7 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.1.tar.gz
Algorithm Hash digest
SHA256 e1af59e74cc2182cd77a72c9d477cc0456c9fe2a3996fc2131c6204da22b0491
MD5 77c05415a9da5ae0d45f6c98c5a4185a
BLAKE2b-256 97d71bd68c89895c10174643e9719dbffac6fbb023007858f1d2367e316a9e39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: markdown_pytest-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eafaa1c18a79b172b29bc162b8009aae1b40820f3ddd67f6b5ba90505f528555
MD5 aff29a62d2d1ae0796bbccce3f5d26d4
BLAKE2b-256 ed3865519aa852cf43945d382c0641c6365b61556568258f40eba73d9cec6458

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