Allow unicode when dumping yaml (#10607)

This commit is contained in:
Andrey 2017-11-16 04:24:08 +02:00 committed by Paulus Schoutsen
parent 3a0c749a12
commit d5cba0b716
2 changed files with 6 additions and 1 deletions

View File

@ -78,7 +78,8 @@ def load_yaml(fname: str) -> Union[List, Dict]:
def dump(_dict: dict) -> str:
"""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')

View File

@ -267,6 +267,10 @@ class TestYaml(unittest.TestCase):
"""The that the dump method returns empty None values."""
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 = {}