Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dev-dependencies = [
"coverage>=7.6.2",
"pre-commit>=4.0.1",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
"pytest-asyncio>=1.1.0",
"ruff>=0.6.9",
"tox>=4.21.2",
]
Expand Down
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import asyncio
import pytest


@pytest.fixture()
def asyncio_event_loop():
e = asyncio.new_event_loop()
yield e
e.close()
8 changes: 4 additions & 4 deletions tests/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ async def test_send_receive(channel_layer):
assert message["text"] == "Ahoy-hoy!"


def test_send_receive_sync(channel_layer, event_loop):
_await = event_loop.run_until_complete
def test_send_receive_sync(channel_layer, asyncio_event_loop):
_await = asyncio_event_loop.run_until_complete
channel = _await(channel_layer.new_channel())
async_to_sync(channel_layer.send, force_new_loop=True)(
channel, {"type": "test.message", "text": "Ahoy-hoy!"}
Expand All @@ -86,8 +86,8 @@ async def test_multi_send_receive(channel_layer):
assert (await channel_layer.receive(channel))["type"] == "message.3"


def test_multi_send_receive_sync(channel_layer, event_loop):
_await = event_loop.run_until_complete
def test_multi_send_receive_sync(channel_layer, asyncio_event_loop):
_await = asyncio_event_loop.run_until_complete
channel = _await(channel_layer.new_channel())
send = async_to_sync(channel_layer.send)
send(channel, {"type": "message.1"})
Expand Down
8 changes: 4 additions & 4 deletions tests/test_pubsub_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ async def test_send_receive(channel_layer):
assert message["text"] == "Ahoy-hoy!"


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


def test_multi_send_receive_sync(channel_layer, event_loop):
_await = event_loop.run_until_complete
def test_multi_send_receive_sync(channel_layer, asyncio_event_loop):
_await = asyncio_event_loop.run_until_complete
channel = _await(channel_layer.new_channel())
send = async_to_sync(channel_layer.send)
send(channel, {"type": "message.1"})
Expand Down
Loading