Trim comment essays and hoist function-local test imports

This commit is contained in:
J. Nick Koston
2026-08-22 11:46:49 -05:00
parent 7e675233c6
commit 4866ef97f0
8 changed files with 25 additions and 63 deletions
@@ -3,10 +3,12 @@
from __future__ import annotations
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
import pytest
from esphome.components import esp8266
from esphome.components.esp8266 import (
ARDUINO_FRAMEWORK_SCHEMA,
_resolve_toolchain,
@@ -120,7 +122,6 @@ def test_decode_pc_native_missing_tools_warns_once(
tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
"""A stack dump of many addresses produces one missing-tool warning."""
from esphome.components import esp8266
esp8266._DECODE_WARNED_AT.clear()
with (
@@ -145,9 +146,6 @@ def test_decode_pc_platformio_missing_tools_warns_once(
"""The PlatformIO branch reports a missing addr2line/ELF at the same
warning level as the native one; raw undecoded addresses with no
stated reason are undiagnosable at default log level."""
from types import SimpleNamespace
from esphome.components import esp8266
esp8266._DECODE_WARNED_AT.clear()
CORE.toolchain = Toolchain.PLATFORMIO
@@ -161,7 +159,6 @@ def test_decode_pc_platformio_missing_tools_warns_once(
def test_resolve_toolchain_rejects_unsupported() -> None:
"""ESP8266 rejects a CLI toolchain it cannot serve, like every platform."""
from esphome.components.esp8266 import _resolve_toolchain
CORE.toolchain = Toolchain.SDK_NRF
with pytest.raises(cv.Invalid, match="Unsupported toolchain 'sdk-nrf'"):
+1 -2
View File
@@ -23,6 +23,7 @@ from esphome.__main__ import (
Purpose,
_get_configured_xtal_freq,
_make_crystal_freq_callback,
_native_toolchain_module,
_redact_with_legacy_fallback,
_resolve_network_devices,
_split_network_devices,
@@ -7341,8 +7342,6 @@ def test_compile_program_espidf_idedata_none_warns(
def test_native_toolchain_module_missing_hook_raises(tmp_path: Path) -> None:
"""A resolved native toolchain whose platform lacks the hook is a bug
and must fail, not silently degrade to the PlatformIO path."""
from esphome.__main__ import _native_toolchain_module
setup_core(platform=PLATFORM_ESP32, tmp_path=tmp_path, name="test_device")
CORE.toolchain = Toolchain.ARDUINO # esp32 provides no hook
with pytest.raises(EsphomeError, match="no native toolchain module"):