_pytest.doctest module¶
discover and run doctests in modules and test files.
-
class
ReprFailDoctest
(reprlocation_lines: Sequence[Tuple[_pytest._code.code.ReprFileLocation, Sequence[str]]])[source]¶ Bases:
_pytest._code.code.TerminalRepr
-
toterminal
(tw: _pytest._io.TerminalWriter) → None[source]¶
-
-
_init_runner_class
() → Type[doctest.DocTestRunner][source]¶
-
_get_runner
(checker: Optional[doctest.OutputChecker] = None, verbose: Optional[bool] = None, optionflags: int = 0, continue_on_failure: bool = True) → doctest.DocTestRunner[source]¶
-
class
DoctestItem
(*k, **kw)[source]¶ Bases:
_pytest.nodes.Item
-
classmethod
from_parent
(parent: Union[_pytest.doctest.DoctestTextfile, _pytest.doctest.DoctestModule], *, name, runner, dtest)[source]¶ the public named constructor
-
classmethod
-
class
DoctestTextfile
(*k, **kw)[source]¶ Bases:
_pytest.python.Module
-
obj
= None¶
-
-
_check_all_skipped
(test)[source]¶ raises pytest.skip() if all examples in the given DocTest have the SKIP option set.
-
_is_mocked
(obj)[source]¶ returns if a object is possibly a mock object by checking the existence of a highly improbable attribute
-
with
_patch_unwrap_mock_aware
()[source]¶ contextmanager which replaces
inspect.unwrap
with a version that’s aware of mock objects and doesn’t recurse on them
-
class
DoctestModule
(*k, **kw)[source]¶ Bases:
_pytest.python.Module
-
_setup_fixtures
(doctest_item)[source]¶ Used by DoctestTextfile and DoctestItem to setup fixture information.
-
_init_checker_class
() → Type[doctest.OutputChecker][source]¶
-
_get_checker
() → doctest.OutputChecker[source]¶ Returns a doctest.OutputChecker subclass that supports some additional options:
ALLOW_UNICODE and ALLOW_BYTES options to ignore u’’ and b’’ prefixes (respectively) in string literals. Useful when the same doctest should run in Python 2 and Python 3.
NUMBER to ignore floating-point differences smaller than the precision of the literal number in the doctest.
An inner class is used to avoid importing “doctest” at the module level.