Skip to content

Commit 57cda77

Browse files
committed
Bring test coverage up
1 parent e27a8fd commit 57cda77

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ async def test_connect(api, mock_command_rsp):
186186
await api.connect()
187187

188188

189+
async def test_connect_failure(api, mock_command_rsp):
190+
transport = None
191+
192+
def mock_version(*args, **kwargs):
193+
nonlocal transport
194+
transport = api._uart._transport
195+
196+
raise asyncio.TimeoutError()
197+
198+
with patch.object(api, "version", side_effect=mock_version):
199+
# We connect but fail to probe
200+
with pytest.raises(asyncio.TimeoutError):
201+
await api.connect()
202+
203+
assert api._uart is None
204+
assert len(transport.close.mock_calls) == 1
205+
206+
189207
async def test_close(api):
190208
await api.connect()
191209

0 commit comments

Comments
 (0)