[Python-Dev] unittest.TestSuite holding references to unittest.TestCase instances too long (original) (raw)

Michael Foord fuzzyman at voidspace.org.uk
Fri Aug 2 17:13:13 CEST 2013


Sent from my iPhone

On 2 Aug 2013, at 14:51, Matt McClure <matthewlmcclure at gmail.com> wrote:

It seems unittest.TestSuite holds references to unittest.TestCase instances after the test runs, until the test suite finishes. In a large suite, where the TestCase instances consume memory during execution, that can lead to exhausting all available memory and the OS killing the test process.

Well individual tests not releasing resources could be seen as a bug in those tests.

That aside, there's an open bug for this with some discussion and a proposed fix:

http://bugs.python.org/issue11798

The agreed on approach just needs doing.

Michael

What do you think of a change like this? $ hg diff diff -r 3bd55ec317a7 Lib/unittest/suite.py --- a/Lib/unittest/suite.py Thu Aug 01 23:57:21 2013 +0200 +++ b/Lib/unittest/suite.py Fri Aug 02 07:42:22 2013 -0400 @@ -90,7 +90,12 @@ if getattr(result, 'testRunEntered', False) is False: result.testRunEntered = topLevel = True - for test in self: + while True: + try: + test = self.tests.pop(0) + except IndexError: + break + if result.shouldStop: break See also the conversation on django-developers[1] that led me here. [1]: https://groups.google.com/forum/#!topic/django-developers/XUMetDSGVT0 -- Matt McClure http://matthewlmcclure.com http://www.mapmyfitness.com/profile/matthewlmcclure


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130802/2242317a/attachment.html>



More information about the Python-Dev mailing list