all Python 3doctestfunction
doctest.set_unittest_reportflags()
unittest integration
Sets the reporting flags (REPORT_*) for doctests run through unittest and returns the previous value.
Syntax
old = doctest.set_unittest_reportflags(flags)
It accepts reporting flags only: ELLIPSIS or NORMALIZE_WHITESPACE raise ValueError — comparison flags go to DocTestSuite(optionflags=...). The setting is global for the whole process, so restore the old value. A useful flag is REPORT_ONLY_FIRST_FAILURE, which keeps a cascade of follow-up failures out of the report.
Examples
import doctest
old = doctest.set_unittest_reportflags(doctest.REPORT_ONLY_FIRST_FAILURE)
print(old) # → 0
try:
doctest.set_unittest_reportflags(doctest.ELLIPSIS)
except ValueError as e:
print(e.args[0]) # → Only reporting flags allowed
doctest.set_unittest_reportflags(old)
See also
Open in the full glossarydocs.python.orgReport an inaccuracy