We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e27a8fd commit 57cda77Copy full SHA for 57cda77
tests/test_api.py
@@ -186,6 +186,24 @@ async def test_connect(api, mock_command_rsp):
186
await api.connect()
187
188
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
207
async def test_close(api):
208
209
0 commit comments