Skip to content

Commit

Permalink
fix some deprecations in tests (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored Aug 10, 2024
1 parent f38f16b commit 7bc85b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions autobahn/asyncio/test/test_aio_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def test_echo_async():
assert 'Hello!' == await echo_async('Hello!', 0)


# @pytest.mark.asyncio(forbid_global_loop=True)
@pytest.mark.skipif(not os.environ.get('USE_ASYNCIO', False), reason='test runs on asyncio only')
def test_websocket_custom_loop(event_loop):
factory = WebSocketServerFactory(loop=event_loop)
Expand All @@ -31,8 +30,7 @@ def test_websocket_custom_loop(event_loop):


@pytest.mark.skipif(not os.environ.get('USE_ASYNCIO', False), reason='test runs on asyncio only')
@pytest.mark.asyncio
async def test_async_on_connect_server(event_loop):
def test_async_on_connect_server(event_loop):

num = 42
done = txaio.create_future()
Expand Down Expand Up @@ -65,7 +63,8 @@ async def on_connect(req):
b'\r\n', # last string doesn't get a \r\n from join()
])
server.processHandshake()
await done

event_loop.run_until_complete(done)

assert len(values) == 1
assert values[0] == num * num
12 changes: 6 additions & 6 deletions autobahn/wamp/test/test_wamp_component_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
from autobahn.asyncio.component import Component

@pytest.mark.skipif(sys.version_info < (3, 5), reason="requires Python 3.5+")
@pytest.mark.asyncio(forbid_global_loop=True)
async def test_asyncio_component(event_loop):
def test_asyncio_component(event_loop):
orig_loop = txaio.config.loop
txaio.config.loop = event_loop

Expand Down Expand Up @@ -72,11 +71,11 @@ def done(f):
txaio.config.loop = orig_loop
assert comp._done_f is None
f.add_done_callback(done)
await finished

event_loop.run_until_complete(finished)

@pytest.mark.skipif(sys.version_info < (3, 5), reason="requires Python 3.5+")
@pytest.mark.asyncio(forbid_global_loop=True)
async def test_asyncio_component_404(event_loop):
def test_asyncio_component_404(event_loop):
"""
If something connects but then gets aborted, it should still try
to re-connect (in real cases this could be e.g. wrong path,
Expand Down Expand Up @@ -151,4 +150,5 @@ def done(f):
finished.set_result(None)
txaio.config.loop = orig_loop
f.add_done_callback(done)
await finished

event_loop.run_until_complete(finished)

0 comments on commit 7bc85b3

Please sign in to comment.