8000 Mock asyncio.sleep for klapprotocol tests (#1130) · python-kasa/python-kasa@8321fd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8321fd0

Browse files
authored
Mock asyncio.sleep for klapprotocol tests (#1130)
Speeds up tests in `test_klapprotocol.py` from 26s to 2s when there's no sleep between the retries.
1 parent 69c2700 commit 8321fd0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kasa/tests/test_klapprotocol.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async def test_protocol_retries_via_client_session(
6767
host = "127.0.0.1"
6868
conn = mocker.patch.object(aiohttp.ClientSession, "post", side_effect=error)
6969
mocker.patch.object(protocol_class, "BACKOFF_SECONDS_AFTER_TIMEOUT", 0)
70+
mocker.patch("asyncio.sleep")
7071

7172
config = DeviceConfig(host)
7273
with pytest.raises(KasaException):
@@ -139,6 +140,8 @@ async def test_protocol_retry_recoverable_error(
139140
"post",
140141
side_effect=aiohttp.ClientOSError("foo"),
141142
)
143+
mocker.patch("asyncio.sleep")
144+
142145
config = DeviceConfig(host)
143146
with pytest.raises(KasaException):
144147
await protocol_class(transport=transport_class(config=config)).query(

0 commit comments

Comments
 (0)
0