{"library":"pytest-markdown-docs","title":"pytest-markdown-docs","description":"pytest-markdown-docs is a pytest plugin that collects and executes Python code blocks found within Markdown files and Python docstrings as tests. It allows developers to ensure that documentation examples remain correct and up-to-date by integrating them into the standard pytest test suite. The library is currently at version 0.9.2 and follows an active, though not strictly fixed, release cadence.","language":"python","status":"active","last_verified":"Wed Apr 15","install":{"commands":["pip install pytest-markdown-docs"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\n\n# Save this content as README.md\nreadme_content = \"\"\"\n# My Project\n\nThis is a sample project with a Python code example.\n\n```python\ndef add(a, b):\n    return a + b\n\nassert add(1, 2) == 3\nassert add(-1, 1) == 0\n```\n\nAnother block that should be skipped:\n```python notest\nprint('This code should not run as a test')\nassert False # This would fail if not skipped\n```\n\"\"\"\n\nwith open('README.md', 'w') as f:\n    f.write(readme_content)\n\n# To run this, save the above content as a Python file (e.g., quickstart.py),\n# then execute from your terminal:\n# python -c \"import quickstart\" # Creates README.md\n# pytest --markdown-docs README.md\n#\n# Expected output will show 2 passed tests from the first code block.","lang":"python","description":"To use pytest-markdown-docs, install it and then simply invoke pytest with the `--markdown-docs` flag, pointing it to your Markdown files or Python modules containing docstrings. The plugin will discover and run code fences tagged as `python`, `python3`, or `py`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}