Author: russellm
Date: 2008-07-20 01:32:54 -0500 (Sun, 20 Jul 2008)
New Revision: 8004

Modified:
   django/trunk/tests/regressiontests/dispatch/tests/test_dispatcher.py
Log:
Fixed #7339 -- Added manual calls to the garbage collector. This is required 
for PyPy and Jython; these implementations don't use reference counting, so you 
can't rely on __del__ being run immediately after del is called. Thanks to 
Maciej Fijalkowski (fijal) and Leo Soto.

Modified: django/trunk/tests/regressiontests/dispatch/tests/test_dispatcher.py
===================================================================
--- django/trunk/tests/regressiontests/dispatch/tests/test_dispatcher.py        
2008-07-20 05:46:41 UTC (rev 8003)
+++ django/trunk/tests/regressiontests/dispatch/tests/test_dispatcher.py        
2008-07-20 06:32:54 UTC (rev 8004)
@@ -2,7 +2,19 @@
 from django.dispatch import dispatcher, robust
 import unittest
 import copy
+import sys
+import gc
 
+if sys.platform.startswith('java'):
+    def garbage_collect():
+        """Run the garbage collector and wait a bit to let it do his work"""
+        import time
+        gc.collect()
+        time.sleep(0.1)
+else:
+    def garbage_collect():
+        gc.collect()
+
 def x(a):
     return a
 
@@ -21,6 +33,7 @@
     
     def setUp(self):
         # track the initial state, since it's possible that others have bleed 
receivers in
+        garbage_collect()
         self.sendersBack = copy.copy(dispatcher.sendersBack)
         self.connections = copy.copy(dispatcher.connections)
         self.senders = copy.copy(dispatcher.senders)
@@ -86,6 +99,7 @@
         connect(a.a, signal, b)
         expected = []
         del a
+        garbage_collect()
         result = send('this',b, a=b)
         self.assertEqual(result, expected)
         self.assertEqual(list(getAllReceivers(b,signal)), [])
@@ -101,6 +115,7 @@
         connect(a, signal, b)
         expected = []
         del a
+        garbage_collect()
         result = send('this',b, a=b)
         self.assertEqual(result, expected)
         self.assertEqual(list(getAllReceivers(b,signal)), [])
@@ -123,6 +138,7 @@
         del a
         del b
         del result
+        garbage_collect()
         self._testIsClean()
     
     def testRobust(self):
@@ -141,4 +157,4 @@
     return unittest.makeSuite(DispatcherTests,'test')
 
 if __name__ == "__main__":
-    unittest.main ()
+    unittest.main()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to