From 28e5659eee55f7a98d0946e2435d92236d91fddd Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 16 Jan 2017 22:08:47 -0800 Subject: [PATCH] Fix load_yaml default value (#5383) --- homeassistant/util/yaml.py | 2 +- tests/util/test_yaml.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/util/yaml.py b/homeassistant/util/yaml.py index 64b63b31ca6..00508862279 100644 --- a/homeassistant/util/yaml.py +++ b/homeassistant/util/yaml.py @@ -60,7 +60,7 @@ def load_yaml(fname: str) -> Union[List, Dict]: with open(fname, encoding='utf-8') as conf_file: # If configuration file is empty YAML returns None # We convert that to an empty dict - return yaml.load(conf_file, Loader=SafeLineLoader) or {} + return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict() except yaml.YAMLError as exc: _LOGGER.error(exc) raise HomeAssistantError(exc) diff --git a/tests/util/test_yaml.py b/tests/util/test_yaml.py index 3305fbea6c9..79fd994ce86 100644 --- a/tests/util/test_yaml.py +++ b/tests/util/test_yaml.py @@ -74,6 +74,12 @@ class TestYaml(unittest.TestCase): doc = yaml.yaml.safe_load(file) assert doc["key"] == "value" + with patch_yaml_files({'test.yaml': None}): + conf = 'key: !include test.yaml' + with io.StringIO(conf) as file: + doc = yaml.yaml.safe_load(file) + assert doc["key"] == {} + @patch('homeassistant.util.yaml.os.walk') def test_include_dir_list(self, mock_walk): """Test include dir list yaml."""