From ba876c44a8d06668e622fb580fdcde45c7a36d48 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Fri, 15 Jan 2021 15:59:44 +0000 Subject: bpo-42934: use TracebackException(compact=True) in unittest.TestResult (GH-24221) --- Lib/unittest/result.py | 3 ++- Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2021-01-15-11-48-00.bpo-42934.ILKoOI.rst diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index 111317b..ce7468e 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -183,7 +183,8 @@ class TestResult(object): 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 0000000..92f2402 --- /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. -- cgit v0.12