summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-19 11:34:54 (GMT)
committerGitHub <noreply@github.com>2023-07-19 11:34:54 (GMT)
commitb1c50b80a6197ba1e41539ec0984a9925956cc1d (patch)
tree4e701e0f8af0a5c980efc701bd97692b3ab8528e /Lib/unittest
parent0c106a91e8e54bbf114cb54540dddb2a39a0e2be (diff)
downloadcpython-b1c50b80a6197ba1e41539ec0984a9925956cc1d.zip
cpython-b1c50b80a6197ba1e41539ec0984a9925956cc1d.tar.gz
cpython-b1c50b80a6197ba1e41539ec0984a9925956cc1d.tar.bz2
[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 70b961ed93f67e34d0624e178f6029c886afaeee) Co-authored-by: Yonatan Bitton <bityob@gmail.com>
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/result.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
index 7757dba..3ace0a5 100644
--- a/Lib/unittest/result.py
+++ b/Lib/unittest/result.py
@@ -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."""