@@ -61,7 +61,8 @@ async def test_send_receive(channel_layer):
6161 assert message ["text" ] == "Ahoy-hoy!"
6262
6363
64- def test_send_receive_sync (channel_layer , event_loop ):
64+ def test_send_receive_sync (channel_layer ):
65+ event_loop = asyncio .new_event_loop ()
6566 _await = event_loop .run_until_complete
6667 channel = _await (channel_layer .new_channel ())
6768 async_to_sync (channel_layer .send , force_new_loop = True )(
@@ -70,6 +71,7 @@ def test_send_receive_sync(channel_layer, event_loop):
7071 message = _await (channel_layer .receive (channel ))
7172 assert message ["type" ] == "test.message"
7273 assert message ["text" ] == "Ahoy-hoy!"
74+ event_loop .close ()
7375
7476
7577@pytest .mark .asyncio
@@ -86,7 +88,8 @@ async def test_multi_send_receive(channel_layer):
8688 assert (await channel_layer .receive (channel ))["type" ] == "message.3"
8789
8890
89- def test_multi_send_receive_sync (channel_layer , event_loop ):
91+ def test_multi_send_receive_sync (channel_layer ):
92+ event_loop = asyncio .new_event_loop ()
9093 _await = event_loop .run_until_complete
9194 channel = _await (channel_layer .new_channel ())
9295 send = async_to_sync (channel_layer .send )
@@ -96,6 +99,7 @@ def test_multi_send_receive_sync(channel_layer, event_loop):
9699 assert _await (channel_layer .receive (channel ))["type" ] == "message.1"
97100 assert _await (channel_layer .receive (channel ))["type" ] == "message.2"
98101 assert _await (channel_layer .receive (channel ))["type" ] == "message.3"
102+ event_loop .close ()
99103
100104
101105@pytest .mark .asyncio
0 commit comments