Skip to content

Commit 1e49c2f

Browse files
authored
Merge pull request #6 from django-utils/version
stop using old event loop fixture
2 parents 6ac70bb + 942d9cc commit 1e49c2f

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dev-dependencies = [
3737
"coverage>=7.6.2",
3838
"pre-commit>=4.0.1",
3939
"pytest>=8.3.3",
40-
"pytest-asyncio>=0.24.0",
40+
"pytest-asyncio>=1.1.0",
4141
"ruff>=0.6.9",
4242
"tox>=4.21.2",
4343
]

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import asyncio
2+
import pytest
3+
4+
5+
@pytest.fixture()
6+
def asyncio_event_loop():
7+
e = asyncio.new_event_loop()
8+
yield e
9+
e.close()

tests/test_pubsub.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +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):
65-
_await = event_loop.run_until_complete
64+
def test_send_receive_sync(channel_layer, asyncio_event_loop):
65+
_await = asyncio_event_loop.run_until_complete
6666
channel = _await(channel_layer.new_channel())
6767
async_to_sync(channel_layer.send, force_new_loop=True)(
6868
channel, {"type": "test.message", "text": "Ahoy-hoy!"}
@@ -86,8 +86,8 @@ async def test_multi_send_receive(channel_layer):
8686
assert (await channel_layer.receive(channel))["type"] == "message.3"
8787

8888

89-
def test_multi_send_receive_sync(channel_layer, event_loop):
90-
_await = event_loop.run_until_complete
89+
def test_multi_send_receive_sync(channel_layer, asyncio_event_loop):
90+
_await = asyncio_event_loop.run_until_complete
9191
channel = _await(channel_layer.new_channel())
9292
send = async_to_sync(channel_layer.send)
9393
send(channel, {"type": "message.1"})

tests/test_pubsub_sentinel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ async def test_send_receive(channel_layer):
4242
assert message["text"] == "Ahoy-hoy!"
4343

4444

45-
def test_send_receive_sync(channel_layer, event_loop):
46-
_await = event_loop.run_until_complete
45+
def test_send_receive_sync(channel_layer, asyncio_event_loop):
46+
_await = asyncio_event_loop.run_until_complete
4747
channel = _await(channel_layer.new_channel())
4848
async_to_sync(channel_layer.send, force_new_loop=True)(
4949
channel, {"type": "test.message", "text": "Ahoy-hoy!"}
@@ -67,8 +67,8 @@ async def test_multi_send_receive(channel_layer):
6767
assert (await channel_layer.receive(channel))["type"] == "message.3"
6868

6969

70-
def test_multi_send_receive_sync(channel_layer, event_loop):
71-
_await = event_loop.run_until_complete
70+
def test_multi_send_receive_sync(channel_layer, asyncio_event_loop):
71+
_await = asyncio_event_loop.run_until_complete
7272
channel = _await(channel_layer.new_channel())
7373
send = async_to_sync(channel_layer.send)
7474
send(channel, {"type": "message.1"})

0 commit comments

Comments
 (0)