Ticket #7339: 7339_test_dispatcher_gc_fix.diff

File 7339_test_dispatcher_gc_fix.diff, 1.9 KB (added by Leo Soto M., 16 years ago)

Fixed a mistake I made on the previous patch

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

    diff -r 9d0e73844d2f 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)  
    2133   
    2234    def setUp(self):
    2335        # track the initial state, since it's possible that others have bleed receivers in
     36        garbage_collect()
    2437        self.sendersBack = copy.copy(dispatcher.sendersBack)
    2538        self.connections = copy.copy(dispatcher.connections)
    2639        self.senders = copy.copy(dispatcher.senders)
    class DispatcherTests(unittest.TestCase)  
    8699        connect(a.a, signal, b)
    87100        expected = []
    88101        del a
     102        garbage_collect()
    89103        result = send('this',b, a=b)
    90104        self.assertEqual(result, expected)
    91105        self.assertEqual(list(getAllReceivers(b,signal)), [])
    class DispatcherTests(unittest.TestCase)  
    101115        connect(a, signal, b)
    102116        expected = []
    103117        del a
     118        garbage_collect()
    104119        result = send('this',b, a=b)
    105120        self.assertEqual(result, expected)
    106121        self.assertEqual(list(getAllReceivers(b,signal)), [])
    class DispatcherTests(unittest.TestCase)  
    123138        del a
    124139        del b
    125140        del result
     141        garbage_collect()
    126142        self._testIsClean()
    127143   
    128144    def testRobust(self):
Back to Top