>>> doctest._unittest_reportflags == (REPORT_NDIFF |
... REPORT_ONLY_FIRST_FAILURE)
True
-
+
Only reporting flags can be set:
>>> set_unittest_reportflags(ELLIPSIS)
if nrflags:
raise ValueError("Invalid flags passed", flags)
-
+
global _unittest_reportflags
old = _unittest_reportflags
_unittest_reportflags = flags
return old
-
+
class FakeModule:
"""Fake module created by tests
"""
-
+
def __init__(self, dict, name):
self.__dict__ = dict
self.__name__ = name
def setUp(self):
test = self._dt_test
-
+
if self._dt_setUp is not None:
self._dt_setUp(test)
old = sys.stdout
new = StringIO()
optionflags = self._dt_optionflags
-
+
if not (optionflags & valid_unittest_reportflags):
# The option flags don't include any reporting flags,
# so add the default reporting flags
optionflags |= _unittest_reportflags
-
+
runner = DocTestRunner(optionflags=optionflags,
checker=self._dt_checker, verbose=False)
optionflags
A set of doctest option flags expressed as an integer.
-
+
"""
suite = unittest.TestSuite()
Here, we didn't need to use a tearDown function because we
modified the test globals. The test globals are
automatically cleared for us after a test.
-
+
"""
def test_trailing_space_in_test():
NameError: name 'favorite_color' is not defined
<BLANKLINE>
<BLANKLINE>
-
+
We get only the first failure.
If we give any reporting options when we set up the tests,