mirror of
https://github.com/esphome/esphome.git
synced 2026-10-09 04:16:01 +00:00
[ci] Stop the toolchain tests from installing ESP-IDF (#20413)
This commit is contained in:
@@ -18,6 +18,7 @@ from unittest.mock import Mock, patch
|
||||
import pytest
|
||||
|
||||
from esphome.core import CORE
|
||||
from esphome.espidf import toolchain
|
||||
|
||||
here = Path(__file__).parent
|
||||
|
||||
@@ -26,6 +27,21 @@ package_root = here.parent.parent
|
||||
sys.path.insert(0, package_root.as_posix())
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_idf_install(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Fail any test that would install ESP-IDF for real.
|
||||
|
||||
An unmocked ``_get_idf_env`` reaches ``check_esp_idf_install``, which
|
||||
downloads the framework on a bare CI runner (minutes on Windows). The
|
||||
install path's own tests call it through ``esphome.espidf.framework``.
|
||||
"""
|
||||
|
||||
def refuse(*args: object, **kwargs: object) -> None:
|
||||
raise AssertionError("test would install ESP-IDF; mock _get_idf_env")
|
||||
|
||||
monkeypatch.setattr(toolchain, "check_esp_idf_install", refuse)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_core():
|
||||
"""Reset CORE after each test."""
|
||||
|
||||
@@ -1519,6 +1519,7 @@ def test_run_reconfigure_flip_into_skip_mode_cleans_up(setup_core: Path) -> None
|
||||
with (
|
||||
patch.object(toolchain, "_skip_bootloader", return_value=True),
|
||||
patch.object(toolchain, "_get_idf_tool", side_effect=lambda n: f"/tools/{n}"),
|
||||
patch.object(toolchain, "_get_idf_env", return_value={}),
|
||||
patch.object(toolchain, "_tool_env", return_value={}),
|
||||
patch.object(toolchain, "run_build_tool", return_value=0),
|
||||
patch.object(toolchain, "_idf_py") as mock_idf_py,
|
||||
@@ -1542,6 +1543,7 @@ def test_run_reconfigure_skip_steady_state_cleans_nothing(setup_core: Path) -> N
|
||||
with (
|
||||
patch.object(toolchain, "_skip_bootloader", return_value=True),
|
||||
patch.object(toolchain, "_get_idf_tool", side_effect=lambda n: f"/tools/{n}"),
|
||||
patch.object(toolchain, "_get_idf_env", return_value={}),
|
||||
patch.object(toolchain, "_tool_env", return_value={}),
|
||||
patch.object(toolchain, "run_build_tool", return_value=0),
|
||||
patch.object(toolchain, "_idf_py") as mock_idf_py,
|
||||
|
||||
Reference in New Issue
Block a user