File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import pytest
1111
1212import zeroconf as r
13- from zeroconf import _engine , const
13+ from zeroconf import _engine , _listener , const
1414from zeroconf .asyncio import AsyncZeroconf
1515
1616log = logging .getLogger ("zeroconf" )
@@ -108,6 +108,24 @@ async def test_connection_lost_prunes_transport(aiozc_loopback: AsyncZeroconf) -
108108 assert protocol not in engine .protocols
109109
110110
111+ @pytest .mark .asyncio
112+ async def test_connection_lost_without_transport_is_noop (aiozc_loopback : AsyncZeroconf ) -> None :
113+ """connection_lost on a listener that never bound a transport leaves the lists intact."""
114+ await aiozc_loopback .zeroconf .async_wait_for_start ()
115+ engine = aiozc_loopback .zeroconf .engine
116+ reader_count = len (engine .readers )
117+ sender_count = len (engine .senders )
118+ protocol_count = len (engine .protocols )
119+
120+ orphan = _listener .AsyncListener (aiozc_loopback .zeroconf )
121+ assert orphan .transport is None
122+ orphan .connection_lost (None )
123+
124+ assert len (engine .readers ) == reader_count
125+ assert len (engine .senders ) == sender_count
126+ assert len (engine .protocols ) == protocol_count
127+
128+
111129@pytest .mark .asyncio
112130async def test_async_close_propagates_outer_cancellation (aiozc_loopback : AsyncZeroconf ) -> None :
113131 """Outer-task cancellation while awaiting setup propagates to the caller."""
You can’t perform that action at this time.
0 commit comments