pytest-doctestplus is a pytest plugin that extends the standard Python doctest functionality with advanced features for testing example code in Python docstrings, reStructuredText (.rst), Markdown (.md), and TeX (.tex) files. It is currently at version 1.7.1 and maintains a consistent release cadence with new features, bug fixes, and compatibility updates for Python and pytest versions.
pip install pytest-doctestplusNo compatibility data collected yet for this library.
To quickly test doctests using pytest-doctestplus, place your doctests in docstrings or .rst files. Then, simply invoke pytest with the `--doctest-plus` flag. This example shows a simple function with a doctest and how to run it, including a skipped test using a doctest directive.
Upgrade your Python environment to 3.10 or a later supported version.
Upgrade your pytest installation to version 8.0 or newer (e.g., `pip install -U pytest`).
When you intend to use the advanced features of pytest-doctestplus, always use the `--doctest-plus` command-line option, and avoid `--doctest-modules`.
Ensure that the required modules are importable. If encountering unexpected skips, verify the `__doctest_requires__` definition. Version 1.7.1 fixed a bug where constraints were not correctly handled.
Ensure doctest directives are used correctly according to the documentation, especially regarding expected content or lack thereof.