Skip to content

Commit 01ef6ff

Browse files
authored
test: pass timeout=200 to ServiceInfo-request timeout tests (#1677)
1 parent 5cfb09d commit 01ef6ff

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

tests/services/test_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,12 +1050,12 @@ def test_request_timeout():
10501050
"""Test that the timeout does not throw an exception and finishes close to the actual timeout."""
10511051
zeroconf = r.Zeroconf(interfaces=["127.0.0.1"])
10521052
start_time = r.current_time_millis()
1053-
assert zeroconf.get_service_info("_notfound.local.", "notthere._notfound.local.") is None
1053+
assert zeroconf.get_service_info("_notfound.local.", "notthere._notfound.local.", timeout=200) is None
10541054
end_time = r.current_time_millis()
10551055
zeroconf.close()
1056-
# 3000ms for the default timeout
1056+
# 200ms for the timeout passed above
10571057
# 1000ms for loaded systems + schedule overhead
1058-
assert (end_time - start_time) < 3000 + 1000
1058+
assert (end_time - start_time) < 200 + 1000
10591059

10601060

10611061
@pytest.mark.asyncio
@@ -1888,7 +1888,7 @@ def async_send(out: DNSOutgoing, addr: str | None = None, port: int = const._MDN
18881888
# patch the zeroconf send
18891889
with patch.object(aiozc.zeroconf, "async_send", async_send):
18901890
await aiozc.async_get_service_info(
1891-
f"willnotbefound.{type_}", type_, question_type=r.DNSQuestionType.QU
1891+
f"willnotbefound.{type_}", type_, timeout=200, question_type=r.DNSQuestionType.QU
18921892
)
18931893

18941894
await aiozc.async_close()

tests/test_asyncio.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,12 +1276,15 @@ async def test_async_request_timeout():
12761276
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
12771277
await aiozc.zeroconf.async_wait_for_start()
12781278
start_time = current_time_millis()
1279-
assert await aiozc.async_get_service_info("_notfound.local.", "notthere._notfound.local.") is None
1279+
assert (
1280+
await aiozc.async_get_service_info("_notfound.local.", "notthere._notfound.local.", timeout=200)
1281+
is None
1282+
)
12801283
end_time = current_time_millis()
12811284
await aiozc.async_close()
1282-
# 3000ms for the default timeout
1285+
# 200ms for the timeout passed above
12831286
# 1000ms for loaded systems + schedule overhead
1284-
assert (end_time - start_time) < 3000 + 1000
1287+
assert (end_time - start_time) < 200 + 1000
12851288

12861289

12871290
@pytest.mark.asyncio

0 commit comments

Comments
 (0)