def set_unittest_reportflags(flags): |
"""Sets the unittest option flags. |
|
The old flag is returned so that a runner could restore the old |
value if it wished to: |
|
>>> import doctest |
>>> old = doctest._unittest_reportflags |
>>> doctest.set_unittest_reportflags(REPORT_NDIFF | |
... REPORT_ONLY_FIRST_FAILURE) == old |
True |
|
>>> doctest._unittest_reportflags == (REPORT_NDIFF | |
... REPORT_ONLY_FIRST_FAILURE) |
True |
|
Only reporting flags can be set: |
|
>>> doctest.set_unittest_reportflags(ELLIPSIS) |
Traceback (most recent call last): |
... |
ValueError: ('Only reporting flags allowed', 8) |
|
>>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF | |
... REPORT_ONLY_FIRST_FAILURE) |
True |
""" |
global _unittest_reportflags |
|
if (flags & REPORTING_FLAGS) != flags: |
raise ValueError("Only reporting flags allowed", flags) |
old = _unittest_reportflags |
_unittest_reportflags = flags |
return old |