mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #22936: Allow showing local variables in unittest errors.
This commit is contained in:
parent
e37a1946c7
commit
f0c819acd0
9 changed files with 118 additions and 32 deletions
|
@ -223,9 +223,16 @@ Command-line options
|
|||
|
||||
Stop the test run on the first error or failure.
|
||||
|
||||
.. cmdoption:: --locals
|
||||
|
||||
Show local variables in tracebacks.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
The command-line options ``-b``, ``-c`` and ``-f`` were added.
|
||||
|
||||
.. versionadded:: 3.5
|
||||
The command-line option ``--locals``.
|
||||
|
||||
The command line can also be used for test discovery, for running all of the
|
||||
tests in a project or just a subset.
|
||||
|
||||
|
@ -1782,12 +1789,10 @@ Loading and running tests
|
|||
|
||||
Set to ``True`` when the execution of tests should stop by :meth:`stop`.
|
||||
|
||||
|
||||
.. attribute:: testsRun
|
||||
|
||||
The total number of tests run so far.
|
||||
|
||||
|
||||
.. attribute:: buffer
|
||||
|
||||
If set to true, ``sys.stdout`` and ``sys.stderr`` will be buffered in between
|
||||
|
@ -1797,7 +1802,6 @@ Loading and running tests
|
|||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
|
||||
.. attribute:: failfast
|
||||
|
||||
If set to true :meth:`stop` will be called on the first failure or error,
|
||||
|
@ -1805,6 +1809,11 @@ Loading and running tests
|
|||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
.. attribute:: tb_locals
|
||||
|
||||
If set to true then local variables will be shown in tracebacks.
|
||||
|
||||
.. versionadded:: 3.5
|
||||
|
||||
.. method:: wasSuccessful()
|
||||
|
||||
|
@ -1815,7 +1824,6 @@ Loading and running tests
|
|||
Returns ``False`` if there were any :attr:`unexpectedSuccesses`
|
||||
from tests marked with the :func:`expectedFailure` decorator.
|
||||
|
||||
|
||||
.. method:: stop()
|
||||
|
||||
This method can be called to signal that the set of tests being run should
|
||||
|
@ -1947,12 +1955,14 @@ Loading and running tests
|
|||
|
||||
|
||||
.. class:: TextTestRunner(stream=None, descriptions=True, verbosity=1, failfast=False, \
|
||||
buffer=False, resultclass=None, warnings=None)
|
||||
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, :data:`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.
|
||||
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 :exc:`DeprecationWarning`,
|
||||
:exc:`PendingDeprecationWarning`, :exc:`ResourceWarning` and
|
||||
|
@ -1971,6 +1981,9 @@ Loading and running tests
|
|||
The default stream is set to :data:`sys.stderr` at instantiation time rather
|
||||
than import time.
|
||||
|
||||
.. versionchanged:: 3.5
|
||||
Added the tb_locals parameter.
|
||||
|
||||
.. method:: _makeResult()
|
||||
|
||||
This method returns the instance of ``TestResult`` used by :meth:`run`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue