diff options
author | mathieui <mathieui@mathieui.net> | 2021-02-14 11:35:03 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-02-20 11:55:46 +0100 |
commit | 7e3e056e6b630411a1d05ffbfbc11b9fe4d45f5c (patch) | |
tree | 94c020b7b61323c533e5fdcbf466d7df51095376 | |
parent | 94700de7a3d9c499dc8ee13d969c3b36126bdc5b (diff) | |
download | slixmpp-7e3e056e6b630411a1d05ffbfbc11b9fe4d45f5c.tar.gz slixmpp-7e3e056e6b630411a1d05ffbfbc11b9fe4d45f5c.tar.bz2 slixmpp-7e3e056e6b630411a1d05ffbfbc11b9fe4d45f5c.tar.xz slixmpp-7e3e056e6b630411a1d05ffbfbc11b9fe4d45f5c.zip |
slixtest: add more shortcuts for asyncio workflow
-rw-r--r-- | slixmpp/test/slixtest.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/slixmpp/test/slixtest.py b/slixmpp/test/slixtest.py index 668b02c0..d0e380f7 100644 --- a/slixmpp/test/slixtest.py +++ b/slixmpp/test/slixtest.py @@ -434,7 +434,9 @@ class SlixTest(unittest.TestCase): timeout -- Time to wait in seconds for data to be received by a live connection. """ + self.wait_() self.xmpp.data_received(data) + self.wait_() def recv_header(self, sto='', sfrom='', @@ -623,10 +625,20 @@ class SlixTest(unittest.TestCase): loop = asyncio.get_event_loop() future = asyncio.ensure_future(self.xmpp.run_filters(), loop=loop) queue = self.xmpp.waiting_queue - print(queue) loop.run_until_complete(queue.join()) future.cancel() + def wait_(self): + async def yield_some(): + for i in range(100): + await asyncio.sleep(0) + loop = asyncio.get_event_loop() + loop.run_until_complete(yield_some()) + + def run_coro(self, coro): + loop = asyncio.get_event_loop() + loop.run_until_complete(coro) + def stream_close(self): """ Disconnect the dummy XMPP client. |