Skip to main content

A simple module to test your documentation examples with pytest

Project description

markdown-pytest

A simple module to test your documentation examples with pytest.

Markdown:

    ```python
    assert True
    ```

Will be shown as:

assert True

You can use the special value __name__ to check to separate the run example and the test code.

Markdown:

    ```python
    if __name__ == '__main__':
        exit(0)
    if __name__ == 'markdown-pytest':
        assert True
    ```

Will be shown as:

if __name__ == '__main__':
    exit(0)
if __name__ == 'markdown-pytest':
    assert True

Code after the # noqa comment will not be executed.

    ```python
    # noqa
    from universe import antigravity, WrongPlanet

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

Will be shown as:

# noqa
from universe import antigravity, WrongPlanet

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

This README.md file might be tested like this:

$ poetry run pytest -sxv README.md                                                                                                                                    17:20:29 master
=============== test session starts ===============
plugins: md-0.1.0
collected 3 items

README.md::line[16-17] PASSED
README.md::line[36-40] PASSED
README.md::line[60-68] 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.1.5.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

markdown_pytest-0.1.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: markdown_pytest-0.1.5.tar.gz
  • Upload date:
  • Size: 7.1 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.1.5.tar.gz
Algorithm Hash digest
SHA256 317e73013b4d8a21f2c4702911ce1b604a3671d54d138afbed357f0738e2884e
MD5 67a3002e35b801194d13b5cffd9ce759
BLAKE2b-256 953575ecffc802e54c34a315c87a27265a78a952f3cad2eaa62e8e5e7df96ad4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: markdown_pytest-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e50928876feec52708202c7c4d5de1b6c05cbe66e85e1fd28a903b71f91f05c6
MD5 e8cea518e7871ec72bc76f946d9b1c9b
BLAKE2b-256 07199f578579eecf0ffb0327779f6bf62b7e52c4eebca5d55e47c6b3cc8f0934

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