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
6 changes: 6 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ async def _wait_for_response():
asyncio.run_coroutine_threadsafe(_wait_for_response(), zc.loop).result()


def _wait_for_start(zc: Zeroconf) -> None:
"""Wait for all sockets to be up and running."""
assert zc.loop is not None
asyncio.run_coroutine_threadsafe(zc.async_wait_for_start(), zc.loop).result()


@lru_cache(maxsize=None)
def has_working_ipv6():
"""Return True if if the system can bind an IPv6 address."""
Expand Down
5 changes: 4 additions & 1 deletion tests/services/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from zeroconf._services.info import ServiceInfo
from zeroconf.aio import AsyncZeroconf

from .. import has_working_ipv6, _inject_response
from .. import has_working_ipv6, _inject_response, _wait_for_start


log = logging.getLogger('zeroconf')
Expand Down Expand Up @@ -435,6 +435,7 @@ def test_backoff(suppresses_mock):

type_ = "_http._tcp.local."
zeroconf_browser = Zeroconf(interfaces=['127.0.0.1'])
_wait_for_start(zeroconf_browser)

# we are going to patch the zeroconf send to check query transmission
old_send = zeroconf_browser.async_send
Expand Down Expand Up @@ -513,6 +514,7 @@ def test_first_query_delay():
"""
type_ = "_http._tcp.local."
zeroconf_browser = Zeroconf(interfaces=['127.0.0.1'])
_wait_for_start(zeroconf_browser)

# we are going to patch the zeroconf send to check query transmission
old_send = zeroconf_browser.async_send
Expand Down Expand Up @@ -666,6 +668,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
service_removed.set()

zeroconf_browser = Zeroconf(interfaces=['127.0.0.1'])
_wait_for_start(zeroconf_browser)

# we are going to patch the zeroconf send to check packet sizes
old_send = zeroconf_browser.async_send
Expand Down