From: 
Subject: Debian changes

The Debian packaging of zigpy is maintained in git, using a workflow
similar to the one described in dgit-maint-merge(7).
The Debian delta is represented by this one combined patch; there isn't a
patch queue that can be represented as a quilt series.

A detailed breakdown of the changes is available from their canonical
representation -- git commits in the packaging repository.
For example, to see the changes made by the Debian maintainer in the first
upload of upstream version 1.2.3, you could use:

    % git clone https://git.dgit.debian.org/zigpy
    % cd zigpy
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone zigpy`, rather than plain `git clone`.)

We don't use debian/source/options single-debian-patch because it has bugs.
Therefore, NMUs etc. may nevertheless have made additional patches.

---

diff --git a/tests/test_topology.py b/tests/test_topology.py
index c2d729b..96529b2 100644
--- a/tests/test_topology.py
+++ b/tests/test_topology.py
@@ -394,26 +394,41 @@ async def test_periodic_scan_failure(mock_scan, topology):
 
 
 async def test_periodic_scan_priority(topology):
+    scan_started = asyncio.Event()
+    finish_scan = asyncio.Event()
+
     async def _scan(_):
-        await asyncio.sleep(0.5)
+        scan_started.set()
+        await finish_scan.wait()
 
     with mock.patch.object(topology, "_scan", side_effect=_scan) as mock_scan:
         scan_task = asyncio.create_task(topology.scan())
-        await asyncio.sleep(0.1)
+        await scan_started.wait()
+        scan_started.clear()
 
         # Start a periodic scan. It won't have time to run yet, the old scan is running
         topology.start_periodic_scans(0.05)
 
         # Wait for the original scan to finish
+        finish_scan.set()
         await scan_task
+        finish_scan.clear()
 
-        # Start another scan, interrupting the periodic scan
-        await asyncio.sleep(0.15)
-        await topology.scan()
+        while len(mock_scan.mock_calls) < 2:
+            await asyncio.sleep(0)
+
+        # Start another scan, interrupting the periodic scan. Stop the periodic
+        # loop while the manual scan is running so slow schedulers cannot start
+        # another periodic scan before the test tears the loop down.
+        scan_started.clear()
+        scan_task = asyncio.create_task(topology.scan())
+        await scan_started.wait()
 
         # Now we can cancel the periodic scan
         topology.stop_periodic_scans()
         await asyncio.sleep(0)
+        finish_scan.set()
+        await scan_task
 
     # Our two manual scans succeeded and the periodic one was attempted
     assert len(mock_scan.mock_calls) == 3
