diff -r 9d0e73844d2f tests/regressiontests/dispatch/tests/test_dispatcher.py
|
a
|
b
|
from django.dispatch import dispatcher,
|
| 2 | 2 | from django.dispatch import dispatcher, robust |
| 3 | 3 | import unittest |
| 4 | 4 | import copy |
| | 5 | import sys |
| | 6 | import gc |
| | 7 | |
| | 8 | if 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) |
| | 14 | else: |
| | 15 | def garbage_collect(): |
| | 16 | gc.collect() |
| 5 | 17 | |
| 6 | 18 | def x(a): |
| 7 | 19 | return a |
| … |
… |
class DispatcherTests(unittest.TestCase)
|
| 21 | 33 | |
| 22 | 34 | def setUp(self): |
| 23 | 35 | # track the initial state, since it's possible that others have bleed receivers in |
| | 36 | garbage_collect() |
| 24 | 37 | self.sendersBack = copy.copy(dispatcher.sendersBack) |
| 25 | 38 | self.connections = copy.copy(dispatcher.connections) |
| 26 | 39 | self.senders = copy.copy(dispatcher.senders) |
| … |
… |
class DispatcherTests(unittest.TestCase)
|
| 86 | 99 | connect(a.a, signal, b) |
| 87 | 100 | expected = [] |
| 88 | 101 | del a |
| | 102 | garbage_collect() |
| 89 | 103 | result = send('this',b, a=b) |
| 90 | 104 | self.assertEqual(result, expected) |
| 91 | 105 | self.assertEqual(list(getAllReceivers(b,signal)), []) |
| … |
… |
class DispatcherTests(unittest.TestCase)
|
| 101 | 115 | connect(a, signal, b) |
| 102 | 116 | expected = [] |
| 103 | 117 | del a |
| | 118 | garbage_collect() |
| 104 | 119 | result = send('this',b, a=b) |
| 105 | 120 | self.assertEqual(result, expected) |
| 106 | 121 | self.assertEqual(list(getAllReceivers(b,signal)), []) |
| … |
… |
class DispatcherTests(unittest.TestCase)
|
| 123 | 138 | del a |
| 124 | 139 | del b |
| 125 | 140 | del result |
| | 141 | garbage_collect() |
| 126 | 142 | self._testIsClean() |
| 127 | 143 | |
| 128 | 144 | def testRobust(self): |