[Python-checkins] bpo-42934: use TracebackException(compact=True) in unittest.TestResult (GH-24221)

gvanrossum webhook-mailer at python.org
Fri Jan 15 10:59:56 EST 2021


https://github.com/python/cpython/commit/ba876c44a8d06668e622fb580fdcde45c7a36d48
commit: ba876c44a8d06668e622fb580fdcde45c7a36d48
branch: master
author: Irit Katriel <iritkatriel at yahoo.com>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2021-01-15T07:59:44-08:00
summary:

bpo-42934: use TracebackException(compact=True) in unittest.TestResult (GH-24221)

files:
A Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst
M Lib/unittest/result.py

diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
index 111317b329a85..ce7468e31481f 100644
--- a/Lib/unittest/result.py
+++ b/Lib/unittest/result.py
@@ -183,7 +183,8 @@ def _exc_info_to_string(self, err, test):
         else:
             length = None
         tb_e = traceback.TracebackException(
-            exctype, value, tb, limit=length, capture_locals=self.tb_locals)
+            exctype, value, tb,
+            limit=length, capture_locals=self.tb_locals, compact=True)
         msgLines = list(tb_e.format())
 
         if self.buffer:
diff --git a/Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst b/Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst
new file mode 100644
index 0000000000000..92f2402d2324a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst
@@ -0,0 +1,3 @@
+Use :class:`~traceback.TracebackException`'s new ``compact`` param in
+:class:`~unittest.TestResult` to reduce time and memory consumed by
+traceback formatting.



More information about the Python-checkins mailing list