1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 23:32:23 +01:00
This commit is contained in:
J. Nick Koston
2025-06-22 20:03:02 +02:00
parent 85e3b63f05
commit 25ed7c890b

View File

@@ -3,10 +3,11 @@
from collections.abc import Callable
from pathlib import Path
from typing import Any
from unittest.mock import patch
import pytest
from esphome import config, config_validation as cv
from esphome import config, config_validation as cv, yaml_util
from esphome.config import Config
from esphome.const import CONF_AREA, CONF_AREAS, CONF_DEVICES
from esphome.core import CORE
@@ -38,8 +39,15 @@ def load_config_from_yaml(
yaml_file: Callable[[str], str], yaml_content: str
) -> Config | None:
"""Load configuration from YAML content."""
CORE.config_path = yaml_file(yaml_content)
return config.read_config({})
yaml_path = yaml_file(yaml_content)
parsed_yaml = yaml_util.load_yaml(yaml_path)
# Mock yaml_util.load_yaml to return our parsed content
with (
patch.object(yaml_util, "load_yaml", return_value=parsed_yaml),
patch.object(CORE, "config_path", yaml_path),
):
return config.read_config({})
def load_config_from_fixture(