summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorYonatan Bitton <bityob@gmail.com>2023-07-19 11:03:47 (GMT)
committerGitHub <noreply@github.com>2023-07-19 11:03:47 (GMT)
commit70b961ed93f67e34d0624e178f6029c886afaeee (patch)
tree509cb106414f7eb5617b3d4b7ff38b451093aafe /Lib/unittest
parente6f96cf9c62e38514e8f5465a1c43f85d861adb2 (diff)
downloadcpython-70b961ed93f67e34d0624e178f6029c886afaeee.zip
cpython-70b961ed93f67e34d0624e178f6029c886afaeee.tar.gz
cpython-70b961ed93f67e34d0624e178f6029c886afaeee.tar.bz2
gh-104090: Fix unittest collectedDurations resources leak (#106795)
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."""