mirror of
https://github.com/esphome/esphome.git
synced 2026-10-03 17:55:57 +00:00
Skip the user_config deep copy unless esphome config --no-defaults needs it
This commit is contained in:
@@ -370,7 +370,7 @@ def test_validate_config_captures_user_config_snapshot(tmp_path: Path) -> None:
|
||||
"""
|
||||
test_config = _get_test_minimal_valid_config(tmp_path)
|
||||
|
||||
result = config_module.validate_config(test_config, None)
|
||||
result = config_module.validate_config(test_config, None, snapshot_user_config=True)
|
||||
|
||||
# Snapshot is populated.
|
||||
assert result.user_config is not None
|
||||
@@ -393,7 +393,7 @@ def test_validate_config_user_config_snapshot_is_deep_copy(tmp_path: Path) -> No
|
||||
"""
|
||||
test_config = _get_test_minimal_valid_config(tmp_path)
|
||||
|
||||
result = config_module.validate_config(test_config, None)
|
||||
result = config_module.validate_config(test_config, None, snapshot_user_config=True)
|
||||
|
||||
assert result.user_config is not None
|
||||
# preload_core_config injected build_path onto the validated config.
|
||||
@@ -404,6 +404,20 @@ def test_validate_config_user_config_snapshot_is_deep_copy(tmp_path: Path) -> No
|
||||
assert result["esphome"] is not result.user_config["esphome"]
|
||||
|
||||
|
||||
def test_validate_config_skips_user_config_snapshot_by_default(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Without ``snapshot_user_config`` the deep copy is skipped entirely;
|
||||
only ``esphome config --no-defaults`` needs the snapshot and the copy is
|
||||
too expensive to take on every load.
|
||||
"""
|
||||
test_config = _get_test_minimal_valid_config(tmp_path)
|
||||
|
||||
result = config_module.validate_config(test_config, None)
|
||||
|
||||
assert result.user_config is None
|
||||
|
||||
|
||||
def test_merge_config_preserves_ordered_dict() -> None:
|
||||
"""Test that merge_config preserves OrderedDict type.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user