Skip to content

Commit 8496841

Browse files
gh-55594: Document unittest.TextTestRunner class and methods
1 parent 57db125 commit 8496841

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Doc/library/unittest.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,48 @@ Loading and running tests
19991999
.. versionchanged:: 3.13
20002000
*top_level_dir* is only stored for the duration of *discover* call.
20012001

2002+
2003+
.. _testrunner-objects:
2004+
2005+
Test runners
2006+
~~~~~~~~~~~~
2007+
2008+
.. class:: TextTestRunner(stream=None, descriptions=True, verbosity=1,
2009+
warnings=None, *, resultclass=None)
2010+
2011+
A basic test runner implementation that outputs results to a stream.
2012+
2013+
This class has a few configurable parameters, controlling the output:
2014+
2015+
:param stream: The stream to which the test results are printed. By
2016+
default, this is ``sys.stderr``.
2017+
:param descriptions: Controls whether test descriptions are displayed.
2018+
Defaults to ``True``.
2019+
:param verbosity: Controls the verbosity level of the output. Higher
2020+
numbers mean more verbose output. Defaults to ``1``.
2021+
:param warnings: Controls how warnings are handled during the test run.
2022+
See the :mod:`warnings` module documentation for details.
2023+
Defaults to ``None``.
2024+
:param resultclass: The class to instantiate for test results. Defaults
2025+
to :class:`TextTestResult`.
2026+
2027+
.. versionchanged:: 3.1
2028+
Added `warnings` parameter.
2029+
2030+
.. versionchanged:: 3.2
2031+
Added `resultclass` parameter.
2032+
2033+
.. method:: run(test)
2034+
2035+
Run the given test case or test suite.
2036+
2037+
:param test: The :class:`TestCase` or :class:`TestSuite` object to run.
2038+
:returns: The :class:`TestResult` object produced by the test run.
2039+
2040+
This method is commonly used by :func:`unittest.main` to execute tests.
2041+
`unittest.main` will instantiate a :class:`TextTestRunner` and call its
2042+
`run()` method implicitly.
2043+
20022044
.. versionchanged:: 3.14
20032045
*start_dir* can once again be a :term:`namespace package`.
20042046

0 commit comments

Comments
 (0)