June 2019
Beginner to intermediate
770 pages
19h 24m
English
There's a hook in the doctest module that will create a proper unittest.TestSuite from docstring comments. This allows us to use both doctest and unittest in a large application.
What we'll do is create an instance of doctest.DocTestSuite(). This will build a suite from a module's docstrings. If we don't specify a module, the module that is currently running is used to build the suite. We can use a module such as the following one:
import doctest suite5 = doctest.DocTestSuite()
t = unittest.TextTestRunner(verbosity=2)
t.run(suite5)
We built a suite, suite5, from the doctest strings in the current module. We used unittestTextTestRunner on this suite. As an alternative, we can combine the doctest suite with ...
Read now
Unlock full access