From 5a711e455ac1d68f499da57cccd787709fdfb1c6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 6 Feb 2026 16:12:22 +0100 Subject: [PATCH] some more tests --- esphome/yaml_util.py | 1 + tests/unit_tests/test_bundle.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 5aab9d93c6..d03645bb69 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -43,6 +43,7 @@ _LOGGER = logging.getLogger(__name__) SECRET_YAML = "secrets.yaml" _SECRET_CACHE = {} _SECRET_VALUES = {} +# Not thread-safe — config processing is single-threaded today. _load_listeners: list[Callable[[Path], None]] = [] diff --git a/tests/unit_tests/test_bundle.py b/tests/unit_tests/test_bundle.py index 8dac080884..b8b2d0ffd1 100644 --- a/tests/unit_tests/test_bundle.py +++ b/tests/unit_tests/test_bundle.py @@ -761,6 +761,27 @@ def test_discover_files_external_components_local(tmp_path: Path) -> None: assert "components/my_comp/sensor.py" in paths +def test_discover_files_external_components_skips_pycache(tmp_path: Path) -> None: + """__pycache__ directories inside local external_components are excluded.""" + _setup_config_dir( + tmp_path, + files={ + "components/my_comp/__init__.py": "# comp", + "components/my_comp/__pycache__/module.cpython-313.pyc": "bytecode", + }, + ) + + config: dict[str, Any] = { + "external_components": [{"source": {"type": "local", "path": "components"}}], + } + creator = ConfigBundleCreator(config) + files = creator.discover_files() + + paths = [f.path for f in files] + assert "components/my_comp/__init__.py" in paths + assert not any("__pycache__" in p for p in paths) + + def test_discover_files_external_components_non_dict_source(tmp_path: Path) -> None: """external_components with string source (e.g. github shorthand) is skipped.""" _setup_config_dir(tmp_path)