summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/runner.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-03-06 00:46:35 (GMT)
committerRobert Collins <rbtcollins@hp.com>2015-03-06 00:46:35 (GMT)
commitf0c819acd0f85eafe12a7ff706650cb39d3fbf34 (patch)
treebfd78fdedfd364995c6c707ac1f137cb763597e9 /Lib/unittest/runner.py
parente37a1946c7196169b8d3117f65391a12bb8d97f7 (diff)
downloadcpython-f0c819acd0f85eafe12a7ff706650cb39d3fbf34.zip
cpython-f0c819acd0f85eafe12a7ff706650cb39d3fbf34.tar.gz
cpython-f0c819acd0f85eafe12a7ff706650cb39d3fbf34.tar.bz2
Issue #22936: Allow showing local variables in unittest errors.
Diffstat (limited to 'Lib/unittest/runner.py')
-rw-r--r--Lib/unittest/runner.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py
index 28b8865..2112262 100644
--- a/Lib/unittest/runner.py
+++ b/Lib/unittest/runner.py
@@ -126,7 +126,13 @@ class TextTestRunner(object):
resultclass = TextTestResult
def __init__(self, stream=None, descriptions=True, verbosity=1,
- failfast=False, buffer=False, resultclass=None, warnings=None):
+ failfast=False, buffer=False, resultclass=None, warnings=None,
+ *, tb_locals=False):
+ """Construct a TextTestRunner.
+
+ Subclasses should accept **kwargs to ensure compatibility as the
+ interface changes.
+ """
if stream is None:
stream = sys.stderr
self.stream = _WritelnDecorator(stream)
@@ -134,6 +140,7 @@ class TextTestRunner(object):
self.verbosity = verbosity
self.failfast = failfast
self.buffer = buffer
+ self.tb_locals = tb_locals
self.warnings = warnings
if resultclass is not None:
self.resultclass = resultclass
@@ -147,6 +154,7 @@ class TextTestRunner(object):
registerResult(result)
result.failfast = self.failfast
result.buffer = self.buffer
+ result.tb_locals = self.tb_locals
with warnings.catch_warnings():
if self.warnings:
# if self.warnings is set, use it to filter all the warnings