consolidate yaml configuration

workaround ruamel.yaml issue 255,
where once an empty dict or list has been written,
'flow' style is used thereafter, using dense `{key: value}` form
instead of traditional yaml block style.
This commit is contained in:
Min RK
2018-11-01 11:34:16 +01:00
parent d79155380a
commit d331936812
4 changed files with 61 additions and 13 deletions

19
tests/test_yaml.py Normal file
View File

@@ -0,0 +1,19 @@
from tljh.yaml import yaml
def test_no_empty_flow(tmpdir):
path = tmpdir.join("config.yaml")
with path.open("w") as f:
f.write("{}")
# load empty config file
with path.open("r") as f:
config = yaml.load(f)
# set a value
config["key"] = "value"
# write to a file
with path.open("w") as f:
yaml.dump(config, f)
# verify that it didn't use compact '{}' flow-style
with path.open("r") as f:
content = f.read()
assert content.strip() == "key: value"