Split up yaml loaders into multiple files (#23774)
* Start moving parts of yaml utils to own module Move parts of yaml loader out of the single large file and start to create the structure of the yaml loaders in Ansible [0]. [0]: https://github.com/ansible/ansible/tree/devel/lib/ansible/parsing/yaml * Finish yaml migration, update tests and mocks * Move code around to finish the migration * Update the mocks so that `open` is patched in `homeassistant.util.yaml.loader` instead of `homeassistant.util.yaml`. * Updated mypy ignores * Updated external API of `homeasistant.util.yaml`, see below: Checked what part of the api of `homeassistant.util.yaml` was actually called from outside the tests and added an `__ALL__` that contains only these elements. Updated the tests so that references to internal parts of the API (e.g. the yaml module imported into `homeassistant.util.yaml.loader`) are referenced directly from `homeassistant.util.yaml.loader`. In `tests/test_yaml.py` the import `yaml` refers to `homeassistant.util.yaml` and `yaml_loader` refers to `~.loader`. Future work that remains for the next iteration is to create a custom SafeConstructor and refers to that instead of monkey patching `yaml` with custom loaders. * Update mocks in yaml dumper, check_config
This commit is contained in:
1 parent
118d3bc11c
commit
4004867eda
11 files changed
+179
-139
No files matched your search
@@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import light, scene
|
||||
from homeassistant.util import yaml
|
||||
from homeassistant.util.yaml import loader as yaml_loader
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
from tests.components.light import common as common_light
|
||||
@@ -90,7 +90,7 @@ class TestScene(unittest.TestCase):
|
||||
self.light_1.entity_id, self.light_2.entity_id)
|
||||
|
||||
with io.StringIO(config) as file:
|
||||
doc = yaml.yaml.safe_load(file)
|
||||
doc = yaml_loader.yaml.load(file)
|
||||
|
||||
assert setup_component(self.hass, scene.DOMAIN, doc)
|
||||
common.activate(self.hass, 'scene.test')
|
||||
|
||||
Reference in new issue
Block a user