summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2009-04-10 18:58:32 +0000
committerAdrian Holovaty <adrian@holovaty.com>2009-04-10 18:58:32 +0000
commitb366bcc962d6390ecaa462d73fca9004c9e7f44c (patch)
tree3181e648dc95a22772faf6113afc8ee70794f035
parent9e9a2b88e8d2f76cc85fcdad9bd463bf77181418 (diff)
downloaddjango-b366bcc962d6390ecaa462d73fca9004c9e7f44c.tar.gz
Fixed #10753 -- Fixed regression in dispatcher after [10398]. Thanks for the patch and tests, minmax
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10497 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/dispatch/dispatcher.py1
-rw-r--r--tests/regressiontests/dispatch/tests/test_dispatcher.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py
index bb60fc906d..07377d6411 100644
--- a/django/dispatch/dispatcher.py
+++ b/django/dispatch/dispatcher.py
@@ -124,6 +124,7 @@ class Signal(object):
(r_key, _) = self.receivers[index]
if r_key == lookup_key:
del self.receivers[index]
+ break
def send(self, sender, **named):
"""Send signal from sender to all connected receivers.
diff --git a/tests/regressiontests/dispatch/tests/test_dispatcher.py b/tests/regressiontests/dispatch/tests/test_dispatcher.py
index baaae9cd95..adf760386c 100644
--- a/tests/regressiontests/dispatch/tests/test_dispatcher.py
+++ b/tests/regressiontests/dispatch/tests/test_dispatcher.py
@@ -103,6 +103,19 @@ class DispatcherTests(unittest.TestCase):
a_signal.disconnect(fails)
self._testIsClean(a_signal)
+ def testDisconnection(self):
+ receiver_1 = Callable()
+ receiver_2 = Callable()
+ receiver_3 = Callable()
+ a_signal.connect(receiver_1)
+ a_signal.connect(receiver_2)
+ a_signal.connect(receiver_3)
+ a_signal.disconnect(receiver_1)
+ del receiver_2
+ garbage_collect()
+ a_signal.disconnect(receiver_3)
+ self._testIsClean(a_signal)
+
def getSuite():
return unittest.makeSuite(DispatcherTests,'test')