[tests] Fix test_show_logs_serial taking 30s due to unmocked serial port wait

The test was calling show_logs() which invokes _wait_for_serial_port("/dev/ttyUSB0").
Since that path doesn't exist in CI/dev environments, it spun in a 30-second polling
loop before returning. Add mock_wait_for_serial_port fixture to skip the wait.
This commit is contained in:
J. Nick Koston
2026-03-17 14:26:24 -10:00
parent b9e8da92c7
commit cdf05263df
+8
View File
@@ -167,6 +167,13 @@ def mock_run_miniterm() -> Generator[Mock]:
yield mock
@pytest.fixture
def mock_wait_for_serial_port() -> Generator[Mock]:
"""Mock _wait_for_serial_port for testing."""
with patch("esphome.__main__._wait_for_serial_port") as mock:
yield mock
@pytest.fixture
def mock_upload_using_esptool() -> Generator[Mock]:
"""Mock upload_using_esptool for testing."""
@@ -1706,6 +1713,7 @@ def test_show_logs_serial(
mock_get_port_type: Mock,
mock_check_permissions: Mock,
mock_run_miniterm: Mock,
mock_wait_for_serial_port: Mock,
) -> None:
"""Test show_logs with serial port."""
setup_core(config={"logger": {}}, platform=PLATFORM_ESP32)