mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 11:13:34 +00:00
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.
This commit is contained in:
parent
69c270055d
commit
8321fd08aa
@ -67,6 +67,7 @@ async def test_protocol_retries_via_client_session(
|
||||
host = "127.0.0.1"
|
||||
conn = mocker.patch.object(aiohttp.ClientSession, "post", side_effect=error)
|
||||
mocker.patch.object(protocol_class, "BACKOFF_SECONDS_AFTER_TIMEOUT", 0)
|
||||
mocker.patch("asyncio.sleep")
|
||||
|
||||
config = DeviceConfig(host)
|
||||
with pytest.raises(KasaException):
|
||||
@ -139,6 +140,8 @@ async def test_protocol_retry_recoverable_error(
|
||||
"post",
|
||||
side_effect=aiohttp.ClientOSError("foo"),
|
||||
)
|
||||
mocker.patch("asyncio.sleep")
|
||||
|
||||
config = DeviceConfig(host)
|
||||
with pytest.raises(KasaException):
|
||||
await protocol_class(transport=transport_class(config=config)).query(
|
||||
|
Loading…
Reference in New Issue
Block a user