summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/result.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/result.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/result.py')
-rw-r--r--Lib/unittest/result.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
index 8e0a643..a18f11b 100644
--- a/Lib/unittest/result.py
+++ b/Lib/unittest/result.py
@@ -45,6 +45,7 @@ class TestResult(object):
self.unexpectedSuccesses = []
self.shouldStop = False
self.buffer = False
+ self.tb_locals = False
self._stdout_buffer = None
self._stderr_buffer = None
self._original_stdout = sys.stdout
@@ -179,9 +180,11 @@ class TestResult(object):
if exctype is test.failureException:
# Skip assert*() traceback levels
length = self._count_relevant_tb_levels(tb)
- msgLines = traceback.format_exception(exctype, value, tb, length)
else:
- msgLines = traceback.format_exception(exctype, value, tb)
+ length = None
+ tb_e = traceback.TracebackException(
+ exctype, value, tb, limit=length, capture_locals=self.tb_locals)
+ msgLines = list(tb_e.format())
if self.buffer:
output = sys.stdout.getvalue()