@@ -61,7 +61,8 @@ async def test_send_receive(channel_layer):
61
61
assert message ["text" ] == "Ahoy-hoy!"
62
62
63
63
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 ()
65
66
_await = event_loop .run_until_complete
66
67
channel = _await (channel_layer .new_channel ())
67
68
async_to_sync (channel_layer .send , force_new_loop = True )(
@@ -70,6 +71,7 @@ def test_send_receive_sync(channel_layer, event_loop):
70
71
message = _await (channel_layer .receive (channel ))
71
72
assert message ["type" ] == "test.message"
72
73
assert message ["text" ] == "Ahoy-hoy!"
74
+ event_loop .close ()
73
75
74
76
75
77
@pytest .mark .asyncio
@@ -86,7 +88,8 @@ async def test_multi_send_receive(channel_layer):
86
88
assert (await channel_layer .receive (channel ))["type" ] == "message.3"
87
89
88
90
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 ()
90
93
_await = event_loop .run_until_complete
91
94
channel = _await (channel_layer .new_channel ())
92
95
send = async_to_sync (channel_layer .send )
@@ -96,6 +99,7 @@ def test_multi_send_receive_sync(channel_layer, event_loop):
96
99
assert _await (channel_layer .receive (channel ))["type" ] == "message.1"
97
100
assert _await (channel_layer .receive (channel ))["type" ] == "message.2"
98
101
assert _await (channel_layer .receive (channel ))["type" ] == "message.3"
102
+ event_loop .close ()
99
103
100
104
101
105
@pytest .mark .asyncio
0 commit comments