From 5f2fc67c40f0cd73bee7b2cf3bc3a73d83832a50 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 7 Dec 2010 17:19:39 -0500 Subject: Added option for iq.send to accept a callhandler. The callback will be a stream level handler, and will not execute in its own thread. If you must have a thread, have the callback function raise a custom event, which can be processed by another event handler, which may run in an individual thread, like so: def handle_reply(self, iq): self.event('custom_event', iq) def do_long_operation_in_thread(self, iq): ... self.add_event_handler('custom_event', self.do_long_operation_in_thread) ...take out already prepared iq stanza... iq.send(callback=self.handle_reply) --- sleekxmpp/test/sleektest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/test/sleektest.py') diff --git a/sleekxmpp/test/sleektest.py b/sleekxmpp/test/sleektest.py index f1b5ef93..e11be5d6 100644 --- a/sleekxmpp/test/sleektest.py +++ b/sleekxmpp/test/sleektest.py @@ -52,6 +52,10 @@ class SleekTest(unittest.TestCase): compare -- Compare XML objects against each other. """ + def __init__(self, *args, **kwargs): + unittest.TestCase.__init__(self, *args, **kwargs) + self.xmpp = None + def runTest(self): pass @@ -86,7 +90,7 @@ class SleekTest(unittest.TestCase): Arguments: xml -- An XML object to use for the Message's values. """ - return Message(None, *args, **kwargs) + return Message(self.xmpp, *args, **kwargs) def Iq(self, *args, **kwargs): """ @@ -97,7 +101,7 @@ class SleekTest(unittest.TestCase): Arguments: xml -- An XML object to use for the Iq's values. """ - return Iq(None, *args, **kwargs) + return Iq(self.xmpp, *args, **kwargs) def Presence(self, *args, **kwargs): """ @@ -108,7 +112,7 @@ class SleekTest(unittest.TestCase): Arguments: xml -- An XML object to use for the Iq's values. """ - return Presence(None, *args, **kwargs) + return Presence(self.xmpp, *args, **kwargs) def check_jid(self, jid, user=None, domain=None, resource=None, bare=None, full=None, string=None): -- cgit v1.2.3