Skip to content

Commit

Permalink
gh-104090: Fix unittest collectedDurations resources leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bityob committed Jul 16, 2023
1 parent 83bd568 commit 509636a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/unittest/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def addDuration(self, test, elapsed):
"""
# support for a TextTestRunner using an old TestResult class
if hasattr(self, "collectedDurations"):
self.collectedDurations.append((test, elapsed))
# Pass test repr and not the test object itself to avoid resources leak
self.collectedDurations.append((str(test), elapsed))

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

0 comments on commit 509636a

Please sign in to comment.