mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Allow unicode when dumping yaml (#10607)
This commit is contained in:
parent
3a0c749a12
commit
d5cba0b716
@ -78,7 +78,8 @@ def load_yaml(fname: str) -> Union[List, Dict]:
|
|||||||
|
|
||||||
def dump(_dict: dict) -> str:
|
def dump(_dict: dict) -> str:
|
||||||
"""Dump YAML to a string and remove null."""
|
"""Dump YAML to a string and remove null."""
|
||||||
return yaml.safe_dump(_dict, default_flow_style=False) \
|
return yaml.safe_dump(
|
||||||
|
_dict, default_flow_style=False, allow_unicode=True) \
|
||||||
.replace(': null\n', ':\n')
|
.replace(': null\n', ':\n')
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,6 +267,10 @@ class TestYaml(unittest.TestCase):
|
|||||||
"""The that the dump method returns empty None values."""
|
"""The that the dump method returns empty None values."""
|
||||||
assert yaml.dump({'a': None, 'b': 'b'}) == 'a:\nb: b\n'
|
assert yaml.dump({'a': None, 'b': 'b'}) == 'a:\nb: b\n'
|
||||||
|
|
||||||
|
def test_dump_unicode(self):
|
||||||
|
"""The that the dump method returns empty None values."""
|
||||||
|
assert yaml.dump({'a': None, 'b': 'привет'}) == 'a:\nb: привет\n'
|
||||||
|
|
||||||
|
|
||||||
FILES = {}
|
FILES = {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user