summaryrefslogtreecommitdiff
path: root/tests/test_events.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-09-23 12:03:49 -0400
committerLance Stout <lancestout@gmail.com>2011-09-23 12:03:49 -0400
commit262da78ca7c5b71901f0f23111ef65156ac56463 (patch)
treeb27bd7c9e42d830ea5cb13be7072c7f3c89a844e /tests/test_events.py
parent0b83edf439dd4d934eb779454f865df5e46fecf8 (diff)
downloadslixmpp-262da78ca7c5b71901f0f23111ef65156ac56463.tar.gz
slixmpp-262da78ca7c5b71901f0f23111ef65156ac56463.tar.bz2
slixmpp-262da78ca7c5b71901f0f23111ef65156ac56463.tar.xz
slixmpp-262da78ca7c5b71901f0f23111ef65156ac56463.zip
Fix del_event_handler for Python3 (different semantics for filter()).
Fixes issue #103
Diffstat (limited to 'tests/test_events.py')
-rw-r--r--tests/test_events.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_events.py b/tests/test_events.py
index ea4cf8a4..fb34be30 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -48,6 +48,29 @@ class TestEvents(SleekTest):
msg = "Event was not triggered the correct number of times: %s"
self.failUnless(happened == [True], msg % happened)
+ def testAddDelAddEvent(self):
+ """Test adding, then removing, then adding an event handler."""
+ happened = []
+
+ def handletestevent(event):
+ happened.append(True)
+
+ self.xmpp.add_event_handler("test_event", handletestevent)
+ self.xmpp.event("test_event", {})
+
+ self.xmpp.del_event_handler("test_event", handletestevent)
+ # Should not trigger because it was deleted
+ self.xmpp.event("test_event", {})
+
+ self.xmpp.add_event_handler("test_event", handletestevent)
+ self.xmpp.event("test_event", {})
+
+ # Give the event queue time to process.
+ time.sleep(0.1)
+
+ msg = "Event was not triggered the correct number of times: %s"
+ self.failUnless(happened == [True, True], msg % happened)
+
def testDisposableEvent(self):
"""Test disposable handler working, then not being triggered again."""
happened = []