mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00: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:
		
							
								
								
									
										12
									
								
								tests/unit_tests/fixtures/yaml_util/missing_comp.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/unit_tests/fixtures/yaml_util/missing_comp.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| esphome: | ||||
|   name: test | ||||
|  | ||||
| esp32: | ||||
|   board: esp32dev | ||||
|  | ||||
| wifi: | ||||
|   ap: ~ | ||||
|  | ||||
| image: | ||||
|   - id: its_a_bug | ||||
|     file: "mdi:bug" | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user