Skip to content

Commit cd765e8

Browse files
committed
test: pin async_remove_listener tolerance of unregistered listener
Demonstrates GHSA-5pv9-xcmm-gqc7: set.remove() raises KeyError, which the except ValueError clause cannot catch.
1 parent 44433dd commit cd765e8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/test_handlers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,3 +2107,17 @@ def async_update_records_complete(self) -> None:
21072107
# This should not raise RuntimeError: set changed size during iteration
21082108
zc.record_manager.async_updates_complete(False)
21092109
await aiozc.async_close()
2110+
2111+
2112+
@pytest.mark.asyncio
2113+
async def test_async_remove_listener_missing_does_not_raise():
2114+
"""Removing a listener that was never registered must not raise."""
2115+
2116+
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
2117+
zc: Zeroconf = aiozc.zeroconf
2118+
2119+
listener = r.RecordUpdateListener()
2120+
2121+
zc.record_manager.async_remove_listener(listener)
2122+
2123+
await aiozc.async_close()

0 commit comments

Comments
 (0)