8000 gh-104090: Fix unittest collectedDurations resources leak · python/cpython@509636a · GitHub
[go: up one dir, main page]

Skip to content

Commit 509636a

Browse files
committed
gh-104090: Fix unittest collectedDurations resources leak
1 parent 83bd568 commit 509636a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/unittest/result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def addDuration(self, test, elapsed):
166166
"""
167167
# support for a TextTestRunner using an old TestResult class
168168
if hasattr(self, "collectedDurations"):
169-
self.collectedDurations.append((test, elapsed))
169+
# Pass test repr and not the test object itself to avoid resources leak
170+
self.collectedDurations.append((str(test), elapsed))
170171

171172
def wasSuccessful(self):
172173
"""Tells whether or not this result was a success."""

0 commit comments

Comments
 (0)
0