Mercurial > hgrepos > Python > libs > ConfigMix
changeset 119:eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Thu, 29 Mar 2018 12:37:20 +0200 |
| parents | e37fc67ae7f3 |
| children | ba5970a2dcef |
| files | tests/test.py |
| diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test.py Thu Mar 29 10:08:26 2018 +0200 +++ b/tests/test.py Thu Mar 29 12:37:20 2018 +0200 @@ -4,6 +4,7 @@ import os import unittest import platform +import io sys.path.insert( 0, @@ -59,7 +60,8 @@ self.__check_types(cfg) def test03_yaml_types(self): - with open(os.path.join(TESTDATADIR, "conf1.yml"), "rt") as f: + with io.open(os.path.join(TESTDATADIR, "conf1.yml"), "rt", + encoding="utf-8") as f: cfg = configmix.yaml.safe_load(f) self.__check_types(cfg) @@ -86,7 +88,8 @@ self.__check_tree(cfg) def test08_yaml_tree(self): - with open(os.path.join(TESTDATADIR, "conf10.yml"), "rt") as f: + with io.open(os.path.join(TESTDATADIR, "conf10.yml"), "rt", + encoding="utf-8") as f: cfg = configmix.yaml.safe_load(f) self.__check_tree(cfg)
