Skip to content

Commit 034565c

Browse files
committed
Update test case
1 parent 81b2387 commit 034565c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tests/test_core.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,14 @@ def mock_split_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNS
249249
zeroconf.close()
250250

251251

252-
def test_notify_listeners():
252+
# This test uses asyncio because it needs to verify the listeners
253+
# run in the event loop
254+
@pytest.mark.asyncio
255+
async def test_notify_listeners():
253256
"""Test adding and removing notify listeners."""
254257
# instantiate a zeroconf instance
255-
zc = Zeroconf(interfaces=['127.0.0.1'])
258+
aiozc = AsyncZeroconf(interfaces=['127.0.0.1'])
259+
zc = aiozc.zeroconf
256260
notify_called = 0
257261

258262
class TestNotifyListener(r.NotifyListener):
@@ -281,10 +285,11 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
281285
# start a browser
282286
browser = ServiceBrowser(zc, "_http._tcp.local.", [on_service_state_change])
283287
browser.cancel()
288+
await asyncio.sleep(0)
284289

285290
assert not notify_called
286291

287-
zc.close()
292+
await aiozc.async_close()
288293

289294

290295
def test_generate_service_query_set_qu_bit():

0 commit comments

Comments
 (0)