From 8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 31 May 2011 12:48:43 -0700 Subject: Begin experimental use of exceptions. Provides IqTimeout and IqError which are raised when an Iq response does not arrive in time, or it arrives with type='error'. --- tests/test_stream_handlers.py | 5 ++++- tests/test_stream_roster.py | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py index dae4456d..1b831e21 100644 --- a/tests/test_stream_handlers.py +++ b/tests/test_stream_handlers.py @@ -90,7 +90,10 @@ class TestHandlers(SleekTest): iq['id'] = 'test2' iq['type'] = 'set' iq['query'] = 'test2' - reply = iq.send(block=True, timeout=0) + try: + reply = iq.send(block=True, timeout=0) + except IqTimeout: + pass self.xmpp.add_event_handler('message', waiter_handler, threaded=True) diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py index e1aa1766..95163744 100644 --- a/tests/test_stream_roster.py +++ b/tests/test_stream_roster.py @@ -111,19 +111,12 @@ class TestStreamRoster(SleekTest): def testRosterTimeout(self): """Test handling a timed out roster request.""" self.stream_start() - events = [] - - def roster_timeout(event): - events.append('roster_timeout') - - self.xmpp.add_event_handler('roster_timeout', roster_timeout) - self.xmpp.get_roster(timeout=0) - # Give the event queue time to process. - time.sleep(.1) + def do_test(): + self.xmpp.get_roster(timeout=0) + time.sleep(.1) - self.failUnless(events == ['roster_timeout'], - "Roster timeout event not triggered: %s." % events) + self.assertRaises(IqTimeout, do_test) def testRosterCallback(self): """Test handling a roster request callback.""" -- cgit v1.2.3