pytest-doctest-mkdocstrings


Namepytest-doctest-mkdocstrings JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryRun pytest --doctest-modules with markdown docstrings in code blocks (```)
upload_time2024-03-02 18:34:32
maintainer
docs_urlNone
authorMike Foster
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-doctest-mkdocstrings

A pytest plugin that allows you to use doctest and enclose your example code blocks in ` ``` ` codeblocks (e.g. when building documentation with mkdocs and mkdocstring).

> **v0.1.0 - Breaking change** - you now need to specifically add the command line option `--doctest-mdcodeblocks` when calling pytest

Usually this docstring would fail doctest:

```
    """
    A function description

    Examples:
    --------
    ```
    >>> x = 1
    >>> x
    1
    ```
    """
```

As doctest looks for the output
```
Expected:
    1
    ```
Got:
    1
```

This plugin works by mockeypatching doctests parser when pytest begins each test session and including ` ``` ` as an identifier of the end of an expected result (a `want`).

It only works when doctest is invoked via pytest, not when invoking doctest directly.

If you have code examples or expected results which actually contain ` ``` ` then you'll need to re-write them.

## Usage

> **TL;DR**: invoke pytest with `--doctest-mdcodeblocks`

1. **Strongly recommended** to set up a virtual environment first! (e.g.. `python3 -m venv .venv`, `. .venv/bin/activate`)
1. Install with `pip install pytest-doctest-mkdocstrings`
1. Run pytest: `pytest --doctest-mdcodeblocks --doctest-modules --doctest-glob="*.md"`

You can also add the following to your `pyproject.toml` so that pytest always runs doctests:
```
[tool.pytest.ini_options]
addopts = [
    "--doctest-modules",
    "--doctest-glob='*.md'",
    "--doctest-mdcodeblocks"
]
```

To temporarily override the setting use: `pytest --no-doctest-mdcodeblocks`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pytest-doctest-mkdocstrings",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mike Foster",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/86/86/3f430d371c07ac7f1a391a853d9d675a4422af2337f59ac2431331749252/pytest-doctest-mkdocstrings-0.1.1.tar.gz",
    "platform": null,
    "description": "# pytest-doctest-mkdocstrings\n\nA pytest plugin that allows you to use doctest and enclose your example code blocks in ` ``` ` codeblocks (e.g. when building documentation with mkdocs and mkdocstring).\n\n> **v0.1.0 - Breaking change** - you now need to specifically add the command line option `--doctest-mdcodeblocks` when calling pytest\n\nUsually this docstring would fail doctest:\n\n```\n    \"\"\"\n    A function description\n\n    Examples:\n    --------\n    ```\n    >>> x = 1\n    >>> x\n    1\n    ```\n    \"\"\"\n```\n\nAs doctest looks for the output\n```\nExpected:\n    1\n    ```\nGot:\n    1\n```\n\nThis plugin works by mockeypatching doctests parser when pytest begins each test session and including ` ``` ` as an identifier of the end of an expected result (a `want`).\n\nIt only works when doctest is invoked via pytest, not when invoking doctest directly.\n\nIf you have code examples or expected results which actually contain ` ``` ` then you'll need to re-write them.\n\n## Usage\n\n> **TL;DR**: invoke pytest with `--doctest-mdcodeblocks`\n\n1. **Strongly recommended** to set up a virtual environment first! (e.g.. `python3 -m venv .venv`, `. .venv/bin/activate`)\n1. Install with `pip install pytest-doctest-mkdocstrings`\n1. Run pytest: `pytest --doctest-mdcodeblocks --doctest-modules --doctest-glob=\"*.md\"`\n\nYou can also add the following to your `pyproject.toml` so that pytest always runs doctests:\n```\n[tool.pytest.ini_options]\naddopts = [\n    \"--doctest-modules\",\n    \"--doctest-glob='*.md'\",\n    \"--doctest-mdcodeblocks\"\n]\n```\n\nTo temporarily override the setting use: `pytest --no-doctest-mdcodeblocks`\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Run pytest --doctest-modules with markdown docstrings in code blocks (```)",
    "version": "0.1.1",
    "project_urls": {
        "Changelog": "https://github.com/MusicalNinjaDad/pytest-doctest-mkdocstrings/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/MusicalNinjaDad/pytest-doctest-mkdocstrings",
        "Homepage": "https://github.com/MusicalNinjaDad/pytest-doctest-mkdocstrings",
        "Issues": "https://github.com/MusicalNinjaDad/pytest-doctest-mkdocstrings/issues",
        "Repository": "https://github.com/MusicalNinjaDad/pytest-doctest-mkdocstrings"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "028e7cbab493901a48c0dc8e45e55f126c3bb100693c65c234ebcb9085d55075",
                "md5": "0d4786110b2c07d5fd9cc7218c1cd00c",
                "sha256": "2299264438723ad1b287a0ad6c2e0b30a99e80711381eb6e97284810237b71b2"
            },
            "downloads": -1,
            "filename": "pytest_doctest_mkdocstrings-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d4786110b2c07d5fd9cc7218c1cd00c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6092,
            "upload_time": "2024-03-02T18:34:31",
            "upload_time_iso_8601": "2024-03-02T18:34:31.562767Z",
            "url": "https://files.pythonhosted.org/packages/02/8e/7cbab493901a48c0dc8e45e55f126c3bb100693c65c234ebcb9085d55075/pytest_doctest_mkdocstrings-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86863f430d371c07ac7f1a391a853d9d675a4422af2337f59ac2431331749252",
                "md5": "aa349e8a9c088e13a41404161f8b16a6",
                "sha256": "a3b361e016917a79e268dc4e120a50e216e7f67527d0a53cb454392a077f003a"
            },
            "downloads": -1,
            "filename": "pytest-doctest-mkdocstrings-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "aa349e8a9c088e13a41404161f8b16a6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5572,
            "upload_time": "2024-03-02T18:34:32",
            "upload_time_iso_8601": "2024-03-02T18:34:32.981225Z",
            "url": "https://files.pythonhosted.org/packages/86/86/3f430d371c07ac7f1a391a853d9d675a4422af2337f59ac2431331749252/pytest-doctest-mkdocstrings-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-02 18:34:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MusicalNinjaDad",
    "github_project": "pytest-doctest-mkdocstrings",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytest-doctest-mkdocstrings"
}
        
Elapsed time: 4.46291s