On Thursday, July 18, 2013 7:30:55 PM UTC-7, Matt McClure wrote:

> 1.  TestSuite. Here's a minimal hack to release the reference that 
> TestSuite would otherwise hold after a TestCase runs until the remainder of 
> the suite had finished.
>
> +            self._tests.remove(test)
>

That turns out to be a bad idea because it modifies a list inside a loop 
iterating over it, making the loop skip items it should visit. Here's an 
updated change that doesn't suffer from that problem:

diff --git a/django/utils/unittest/suite.py b/django/utils/unittest/suite.py
index f39569b..8530200 100644
--- a/django/utils/unittest/suite.py
+++ b/django/utils/unittest/suite.py
@@ -1,5 +1,6 @@
 """TestSuite"""
 
+import gc
 import sys
 import unittest
 from django.utils.unittest import case, util
@@ -96,7 +97,11 @@ class TestSuite(BaseTestSuite):
     ################################
     # private methods
     def _wrapped_run(self, result, debug=False):
-        for test in self:
+        while True:
+            try:
+                test = self._tests.pop(0)
+            except IndexError:
+                break
             if result.shouldStop:
                 break
 
@@ -116,6 +121,7 @@ class TestSuite(BaseTestSuite):
                 test(result)
             else:
                 test.debug()
+            #gc.collect()
 
     def _handleClassSetUp(self, test, result):
         previousClass = getattr(result, '_previousTestClass', None)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to