Hi,
I’m pleased to announce the general availability of scipy_doctest
: the enhancement to the standard library doctest
module, which adds floating point awareness to doctest checking. The core tech was used by SciPy and NumPy for quite a while to keep the documentation current, in the form of the redguide-check
internal utility. The scipy_doctest
package provides this fp-aware checking as a standalone, pip-installable package.
Additional features include
- pytest integration: when
scipy_doctest
is installed,$ pytest --doctest-modules
usesscipy_doctest
instead of the standard librarydoctest
module; - flexible doctest finding:
pytest --doctest-collect=api
switch only finds doctests in the public modules (those with names not starting with a leading underscore); - flexible doctest checking: the default checker is heavily informed by the needs of SciPy; Alternative checkers can be specified by just adding a key into the config dictionary
- doctests can be skipped/ignored/xfailed by name through the config dictionary.
Installation
Install it from PyPI:
$ python -mpip install scipy-doctest
Usage
The usual
$ pytest --doctest-modules …
Configuring the behavior
See SciPy’s conftest.py
(scipy/scipy/conftest.py at main · scipy/scipy · GitHub) for examples.
More info
The doctesting layer is the work of multiple NumPy and SciPy contributors. For the pytest integration, special thanks goes to Sheila Kahwai and Melissa Weber Mendoça.
Cheers,
Evgeni