mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-104090: Fix unittest collectedDurations resources leak (GH-106795) (#106888)
gh-104090: Fix unittest collectedDurations resources leak (GH-106795)
(cherry picked from commit 70b961ed93
)
Co-authored-by: Yonatan Bitton <bityob@gmail.com>
This commit is contained in:
parent
0c106a91e8
commit
b1c50b80a6
2 changed files with 3 additions and 1 deletions
|
@ -166,7 +166,8 @@ class TestResult(object):
|
|||
"""
|
||||
# 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."""
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Avoid creating a reference to the test object in :meth:`~unittest.TestResult.collectedDurations`.
|
Loading…
Add table
Add a link
Reference in a new issue