class unittest.TextTestRunner(stream=None, descriptions=True, verbosity=1, failfast=False, buffer=False, resultclass=None, warnings=None, *, tb_locals=False)
A basic test runner implementation that outputs results to a stream. If stream is None
, the default, sys.stderr
is used as the output stream. This class has a few configurable parameters, but is essentially very simple. Graphical applications which run test suites should provide alternate implementations. Such implementations should accept **kwargs
as the interface to construct runners changes when features are added to unittest.
By default this runner shows DeprecationWarning
, PendingDeprecationWarning
, ResourceWarning
and ImportWarning
even if they are ignored by default. Deprecation warnings caused by deprecated unittest methods are also special-cased and, when the warning filters are 'default'
or 'always'
, they will appear only once per-module, in order to avoid too many warning messages. This behavior can be overridden using the -Wd
or -Wa
options and leaving warnings to None
.
Changed in version 3.2: Added the warnings
argument.
Changed in version 3.2: The default stream is set to sys.stderr
at instantiation time rather than import time.
Changed in version 3.5: Added the tb_locals parameter.
-
_makeResult()
-
This method returns the instance of
TestResult
used byrun()
. It is not intended to be called directly, but can be overridden in subclasses to provide a customTestResult
._makeResult()
instantiates the class or callable passed in theTextTestRunner
constructor as theresultclass
argument. It defaults toTextTestResult
if noresultclass
is provided. The result class is instantiated with the following arguments:stream, descriptions, verbosity
-
run(test)
-
This method is the main public interface to the TextTestRunner. This method takes a
TestSuite
orTestCase
instance. ATestResult
is created by calling_makeResult()
and the test(s) are run and the results printed to stdout.
Please login to continue.