@@ -452,9 +452,18 @@ async def test_run_connection_error(self):
452452 async def test_run_syntax_error (self ):
453453 """Test that the stay connected menu is called upon a syntax error when the appropriate flag is active."""
454454
455+ async def passthrough_awaitable (awaitable ):
456+ return await awaitable
457+
455458 # Create a mock hub
456459 mock_hub = AsyncMock ()
457460 mock_hub .connect = AsyncMock ()
461+ mock_hub .race_disconnect = mock_hub .race_power_button_press = AsyncMock (
462+ side_effect = passthrough_awaitable
463+ )
464+
465+ mock_selector = AsyncMock ()
466+ mock_selector .ask_async .side_effect = ["Exit" ]
458467
459468 # Set up mocks using ExitStack
460469 with contextlib .ExitStack () as stack :
@@ -487,8 +496,8 @@ async def test_run_syntax_error(self):
487496 stack .enter_context (
488497 patch ("pybricksdev.ble.find_device" , return_value = "mock_device" )
489498 )
490- mock_menu = stack .enter_context (
491- patch ("pybricksdev.cli.Run.stay_connected_menu" )
499+ mock_selector = stack .enter_context (
500+ patch ("questionary.select" , return_value = mock_selector )
492501 )
493502
494503 # Run the command
@@ -499,7 +508,7 @@ async def test_run_syntax_error(self):
499508 mock_hub_class .assert_called_once_with ("mock_device" )
500509 mock_hub .connect .assert_called_once ()
501510 mock_hub .run .assert_called_once_with (temp_path , True )
502- mock_menu . assert_called_once_with ( mock_hub , args )
511+ mock_selector . assert_called_once ( )
503512 mock_hub .disconnect .assert_called_once ()
504513
505514 @pytest .mark .asyncio
0 commit comments