diff --git a/CHANGELOG b/CHANGELOG index 83f63601c..010154117 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Unreleased ---------- +- add a doctest option for doctest flags + - Improve assertion failure reporting on iterables, by using ndiff and pprint. - removed outdated japanese docs from source tree. diff --git a/_pytest/doctest.py b/_pytest/doctest.py index 729c65b7f..2dd8706ad 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -102,9 +102,6 @@ def get_optionflags(parent): import doctest optionflags_str = parent.config.getini("doctest_optionflags") flag_lookup_table = _get_flag_lookup() - if not optionflags_str: - return doctest.ELLIPSIS - flag_acc = 0 for flag in optionflags_str: flag_acc |= flag_lookup_table[flag] diff --git a/doc/en/customize.txt b/doc/en/customize.txt index ac263b1fa..ab7cda79f 100644 --- a/doc/en/customize.txt +++ b/doc/en/customize.txt @@ -126,3 +126,8 @@ Builtin configuration file options derived class. See :ref:`change naming conventions` for examples. + +.. confval:: doctest_optionflags + + One or more doctest flag names from the standard ``doctest`` module. + `See how py.test handles doctests `_. diff --git a/doc/en/doctest.txt b/doc/en/doctest.txt index c612d9a23..000aa1653 100644 --- a/doc/en/doctest.txt +++ b/doc/en/doctest.txt @@ -60,3 +60,12 @@ It is possible to use fixtures using the ``getfixture`` helper:: Also, :ref:`usefixtures` and :ref:`autouse` fixtures are supported when executing text doctest files. + +The standard ``doctest`` module provides some setting flags to configure the +strictness of doctest tests. In py.test You can enable those flags those flags +using the configuration file. To make pytest ignore trailing whitespaces and +ignore lengthy exception stack traces you can just write:: + + # content of pytest.ini + [pytest] + doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL