1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 19:02:18 +01:00

Ensure filename is shown when YAML raises an error (#6139)

* Ensure filename is shown when YAML raises an error

fixes #5423
fixes #5377

* Ensure filename is shown when YAML raises an error

fixes #5423
fixes #5377

* Ensure filename is shown when YAML raises an error

fixes #5423
fixes #5377

* Ensure filename is shown when YAML raises an error

fixes #5423
fixes #5377

* Ensure filename is shown when YAML raises an error

fixes #5423
fixes #5377
This commit is contained in:
J. Nick Koston
2024-01-23 19:11:03 -10:00
committed by GitHub
parent 23071e932a
commit 25ab6f0297
3 changed files with 48 additions and 8 deletions

View File

@@ -0,0 +1,12 @@
esphome:
name: test
esp32:
board: esp32dev
wifi:
ap: ~
image:
- id: its_a_bug
file: "mdi:bug"

View File

@@ -22,3 +22,23 @@ def test_loading_a_broken_yaml_file(fixture_path):
yaml_util.load_yaml(yaml_file)
except EsphomeError as err:
assert "broken_included.yaml" in str(err)
def test_loading_a_yaml_file_with_a_missing_component(fixture_path):
"""Ensure we show the filename for a yaml file with a missing component."""
yaml_file = fixture_path / "yaml_util" / "missing_comp.yaml"
try:
yaml_util.load_yaml(yaml_file)
except EsphomeError as err:
assert "missing_comp.yaml" in str(err)
def test_loading_a_missing_file(fixture_path):
"""We throw EsphomeError when loading a missing file."""
yaml_file = fixture_path / "yaml_util" / "missing.yaml"
try:
yaml_util.load_yaml(yaml_file)
except EsphomeError as err:
assert "missing.yaml" in str(err)