pytest-sphinx icon indicating copy to clipboard operation
pytest-sphinx copied to clipboard

sphinx doctest plugin for pytest

============= pytest-sphinx

.. image:: https://github.com/thisch/pytest-sphinx/workflows/Test/badge.svg :target: https://github.com/thisch/pytest-sphinx/actions :alt: Action Status

A doctest plugin for pytest, which understands the sphinx-specific directives from doctest-sphinx_. Those sphinx-specific directives can be used in rst files as well as in docstrings of python modules.

Features

  • support for the doctest directive
  • support for testcode and testoutput directives
  • support for testsetup and testcleanup is planned (pull-requests welcome)
  • support for parsing global optionflags (doctest_optionflags) from pytest.ini
  • support for :options: in testoutput
  • support for :skipif: in testcode and in testoutput
  • :hide: is ignored by "pytest-sphinx"

Requirements

  • pytest

Installation

You can install "pytest-sphinx" via pip_ from PyPI_::

$ pip install pytest-sphinx

Usage

  • See doctest-sphinx. Have a look at the examples in doctest-examples.
  • Run pytest with the --doctest-modules flag.

Contributing

Contributions are very welcome. Tests can be run with tox_, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the BSD-3_ license, "pytest-sphinx" is free and open source software

Issues

If you encounter any problems, please file an issue_ along with a detailed description.

.. _doctest-sphinx: http://www.sphinx-doc.org/en/stable/ext/doctest.html .. _doctest-examples: https://github.com/sphinx-doc/sphinx/blob/master/tests/roots/test-ext-doctest/doctest.txt .. _@hackebrot: https://github.com/hackebrot .. _MIT: http://opensource.org/licenses/MIT .. _BSD-3: http://opensource.org/licenses/BSD-3-Clause .. _GNU GPL v3.0: http://www.gnu.org/licenses/gpl-3.0.txt .. _Apache Software License 2.0: http://www.apache.org/licenses/LICENSE-2.0 .. _file an issue: https://github.com/thisch/pytest-sphinx/issues .. _pytest: https://github.com/pytest-dev/pytest .. _tox: https://tox.readthedocs.io/en/latest/ .. _pip: https://pypi.python.org/pypi/pip/ .. _PyPI: https://pypi.python.org/pypi