Skip to content

Commit a13a042

Browse files
committed
Fixed tests for older versions.
Signed-off-by: Pavel Kirilin <[email protected]>
1 parent a1982d9 commit a13a042

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

poetry.lock

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ wemake-python-styleguide = "^0.16.1"
3535
pytest-xdist = { version = "^2.5.0", extras = ["psutil"] }
3636
anyio = "^3.6.1"
3737
pytest-cov = "^3.0.0"
38+
mock = "^4.0.3"
39+
types-mock = "^4.0.15"
3840

3941
[tool.mypy]
4042
strict = true

taskiq_aio_pika/tests/test_broker.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import asyncio
22
import uuid
3-
from unittest import mock
43

54
import pytest
65
from aio_pika import Channel, Message
76
from aio_pika.abc import AbstractExchange, AbstractQueue
87
from aio_pika.exceptions import QueueEmpty
8+
from mock import AsyncMock
99
from taskiq import BrokerMessage
1010

1111
from taskiq_aio_pika.broker import AioPikaBroker
@@ -35,10 +35,10 @@ async def test_kick_success(broker: AioPikaBroker) -> None:
3535

3636
await broker.kick(sent)
3737

38-
callback = mock.AsyncMock()
38+
callback = AsyncMock()
3939

4040
with pytest.raises(asyncio.TimeoutError):
41-
await asyncio.wait_for(broker.listen(callback), timeout=0.2)
41+
await asyncio.wait_for(broker.listen(callback), timeout=0.4)
4242
message = callback.call_args_list[0].args[0]
4343

4444
assert message == sent
@@ -100,10 +100,10 @@ async def test_listen(broker: AioPikaBroker, exchange: AbstractExchange) -> None
100100
routing_key="task_name",
101101
)
102102

103-
callback = mock.AsyncMock()
103+
callback = AsyncMock()
104104

105105
with pytest.raises(asyncio.TimeoutError):
106-
await asyncio.wait_for(broker.listen(callback), timeout=0.2)
106+
await asyncio.wait_for(broker.listen(callback), timeout=0.4)
107107
message = callback.call_args_list[0].args[0]
108108

109109
assert message.message == "test_message"
@@ -129,12 +129,12 @@ async def test_wrong_format(
129129
Message(b"wrong"),
130130
routing_key=queue.name,
131131
)
132-
callback = mock.AsyncMock()
132+
callback = AsyncMock()
133133

134134
with pytest.raises(asyncio.TimeoutError):
135135
await asyncio.wait_for(
136136
broker.listen(callback=callback),
137-
0.2,
137+
0.4,
138138
)
139139

140140
with pytest.raises(QueueEmpty):

0 commit comments

Comments
 (0)