API reference

pytest plugin for doctest w/ reStructuredText and markdown.

pytest_doctest_docutils.pytest_addoption(parser)
function[source]
function[source]
pytest_doctest_docutils.pytest_addoption(parser)

Add options to py.test for doctest_docutils.

Parameters:

parser (Parser)

Return type:

None

pytest_doctest_docutils.pytest_configure(config)
function[source]
function[source]
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.

Parameters:

config (Config)

Return type:

None

pytest_doctest_docutils._unblock_doctest(config)
function[source]
function[source]
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:

bool

pytest_doctest_docutils.pytest_unconfigure()
function[source]
function[source]
pytest_doctest_docutils.pytest_unconfigure()

Unconfigure hook for pytest-doctest-docutils.

Return type:

None

pytest_doctest_docutils.pytest_ignore_collect(collection_path)
function[source]
function[source]
pytest_doctest_docutils.pytest_ignore_collect(collection_path)

Skip Sphinx _build/ output during collection.

pytest’s default norecursedirs excludes build but 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
Parameters:

collection_path (Path)

Return type:

bool | None

pytest_doctest_docutils.pytest_collect_file(file_path, parent)
function[source]
function[source]
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)
function[source]
function[source]
pytest_doctest_docutils._is_doctest(config, path, parent)
Parameters:
Return type:

bool

pytest_doctest_docutils._init_runner_class()
function[source]
function[source]
pytest_doctest_docutils._init_runner_class()
Return type:

type[DocTestRunner]

pytest_doctest_docutils._get_allow_unicode_flag()
function[source]
function[source]
pytest_doctest_docutils._get_allow_unicode_flag()

Register and return the ALLOW_UNICODE flag.

Return type:

int

pytest_doctest_docutils._get_allow_bytes_flag()
function[source]
function[source]
pytest_doctest_docutils._get_allow_bytes_flag()

Register and return the ALLOW_BYTES flag.

Return type:

int

pytest_doctest_docutils._get_number_flag()
function[source]
function[source]
pytest_doctest_docutils._get_number_flag()

Register and return the NUMBER flag.

Return type:

int

pytest_doctest_docutils._get_flag_lookup()
function[source]
function[source]
pytest_doctest_docutils._get_flag_lookup()
Return type:

dict[str, int]

pytest_doctest_docutils.get_optionflags(config)
function[source]
function[source]
pytest_doctest_docutils.get_optionflags(config)

Fetch optionflags from pytest configuration.

Extracted from pytest.doctest 8.0 (license: MIT).

Parameters:

config (Config)

Return type:

int

pytest_doctest_docutils._get_runner(checker=None, verbose=None, optionflags=0, continue_on_failure=True)
function[source]
function[source]
pytest_doctest_docutils._get_runner(checker=None, verbose=None, optionflags=0, continue_on_failure=True)
Parameters:
Return type:

DocTestRunner

class pytest_doctest_docutils.DocutilsDocTestRunner
class pytest_doctest_docutils.DocutilsDocTestRunner

Bases: DocTestRunner

DocTestRunner for doctest_docutils.

class pytest_doctest_docutils.DocTestDocutilsFile
class pytest_doctest_docutils.DocTestDocutilsFile

Bases: Module

Pytest module for doctest_docutils.