Ticket #7339: test_dispatcher_jython_gc_v2.patch

File test_dispatcher_jython_gc_v2.patch, 1.5 KB (added by Leo Soto M., 16 years ago)

patch which also works with jython

  • tests/regressiontests/dispatch/tests/test_dispatcher.py

    diff -r d396f72dbee3 tests/regressiontests/dispatch/tests/test_dispatcher.py
    a b from django.dispatch import dispatcher,  
    22from django.dispatch import dispatcher, robust
    33import unittest
    44import copy
     5import sys
     6import gc
     7
     8if sys.platform.startswith('java'):
     9    def garbage_collect():
     10        """Run the garbage collector and wait a bit to let it do his work"""
     11        import time
     12        gc.collect()
     13        time.sleep(0.1)
     14else:
     15    def garbage_collect():
     16        gc.collect()
    517
    618def x(a):
    719    return a
    class DispatcherTests(unittest.TestCase)  
    8698        connect(a.a, signal, b)
    8799        expected = []
    88100        del a
     101        garbage_collect()
    89102        result = send('this',b, a=b)
    90103        self.assertEqual(result, expected)
    91104        self.assertEqual(list(getAllReceivers(b,signal)), [])
    class DispatcherTests(unittest.TestCase)  
    101114        connect(a, signal, b)
    102115        expected = []
    103116        del a
     117        garbage_collect()
    104118        result = send('this',b, a=b)
    105119        self.assertEqual(result, expected)
    106120        self.assertEqual(list(getAllReceivers(b,signal)), [])
    class DispatcherTests(unittest.TestCase)  
    123137        del a
    124138        del b
    125139        del result
     140        garbage_collect()
    126141        self._testIsClean()
    127142   
    128143    def testRobust(self):
Back to Top