From 7a5bf98f7fadc097f8af77013b8a8c759ea5d888 Mon Sep 17 00:00:00 2001 From: meejah Date: Sun, 27 Nov 2016 15:10:41 -0700 Subject: [PATCH] generic test impl. instead of async/await --- .../asyncio/test/test_asyncio_websocket.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/autobahn/asyncio/test/test_asyncio_websocket.py b/autobahn/asyncio/test/test_asyncio_websocket.py index d5525f2b..3986d067 100644 --- a/autobahn/asyncio/test/test_asyncio_websocket.py +++ b/autobahn/asyncio/test/test_asyncio_websocket.py @@ -36,13 +36,21 @@ class Test(TestCase): def test_async_on_connect_server(self): # see also issue 757 - async def foo(x): - return x * x + # for python 3.5, this can be "async def foo" + def foo(x): + f = txaio.create_future() + txaio.resolve(f, x * x) + return f values = [] - async def on_connect(req): - x = await foo(42) - values.append(x) + def on_connect(req): + f = txaio.create_future() + def cb(x): + f = foo(42) + f.add_callbacks(f, lambda v: values.append(v), None) + return f + txaio.add_callbacks(f, cb, None) + return f factory = WebSocketServerFactory() server = factory()