API reference¶
pytest plugin for doctest w/ reStructuredText and markdown.
See also
This is a derivative of my PR https://github.com/thisch/pytest-sphinx/pull/38 to pytest-sphinx (BSD 3-clause), 2022-09-03.
-
pytest_doctest_docutils.pytest_addoption(parser)¶pytest_doctest_docutils.pytest_addoption(parser)¶
Add options to py.test for doctest_docutils.
-
pytest_doctest_docutils.pytest_configure(config)¶pytest_doctest_docutils.pytest_configure(config)¶
Disable pytest.doctest to prevent running tests twice.
Todo: Find a way to make these plugins cooperate without collecting twice.
-
pytest_doctest_docutils._unblock_doctest(config)¶pytest_doctest_docutils._unblock_doctest(config)¶
Unblock doctest plugin (pytest 8.1+ only).
Re-enables the built-in doctest plugin after it was blocked by pytest_configure. Uses the public unblock() API introduced in pytest 8.1.0.
- Parameters:
config (
pytest.Config) – The pytest configuration object- Returns:
True if unblocked successfully, False if API not available
- Return type:
-
pytest_doctest_docutils.pytest_unconfigure()¶pytest_doctest_docutils.pytest_unconfigure()¶
Unconfigure hook for pytest-doctest-docutils.
- Return type:
-
pytest_doctest_docutils.pytest_ignore_collect(collection_path)¶pytest_doctest_docutils.pytest_ignore_collect(collection_path)¶
Skip Sphinx
_build/output during collection.pytest’s default
norecursedirsexcludesbuildbut not_build, so Sphinx output (which mirrors sources, broken relative includes and all) would otherwise be collected and abort the session.>>> import pathlib >>> pytest_ignore_collect(pathlib.Path("docs/_build/html/history.md")) True >>> pytest_ignore_collect(pathlib.Path("docs/history.md")) is None True
-
pytest_doctest_docutils.pytest_collect_file(file_path, parent)¶pytest_doctest_docutils.pytest_collect_file(file_path, parent)¶
Test collector for pytest-doctest-docutils.
- Parameters:
- Return type:
DocTestDocutilsFile|DoctestModule|None
-
pytest_doctest_docutils._is_doctest(config, path, parent)¶pytest_doctest_docutils._is_doctest(config, path, parent)¶
-
pytest_doctest_docutils._init_runner_class()¶pytest_doctest_docutils._init_runner_class()¶
- Return type:
-
pytest_doctest_docutils._get_allow_unicode_flag()¶pytest_doctest_docutils._get_allow_unicode_flag()¶
Register and return the ALLOW_UNICODE flag.
- Return type:
-
pytest_doctest_docutils._get_allow_bytes_flag()¶pytest_doctest_docutils._get_allow_bytes_flag()¶
Register and return the ALLOW_BYTES flag.
- Return type:
-
pytest_doctest_docutils._get_number_flag()¶pytest_doctest_docutils._get_number_flag()¶
Register and return the NUMBER flag.
- Return type:
-
pytest_doctest_docutils.get_optionflags(config)¶pytest_doctest_docutils.get_optionflags(config)¶
Fetch optionflags from pytest configuration.
Extracted from pytest.doctest 8.0 (license: MIT).
-
pytest_doctest_docutils._get_runner(checker=None, verbose=None, optionflags=0, continue_on_failure=True)¶pytest_doctest_docutils._get_runner(checker=None, verbose=None, optionflags=0, continue_on_failure=True)¶
- Parameters:
- Return type:
-
class pytest_doctest_docutils.DocutilsDocTestRunner¶class pytest_doctest_docutils.DocutilsDocTestRunner¶
Bases:
DocTestRunnerDocTestRunner for doctest_docutils.