Mercurial > hgrepos > Python > libs > ConfigMix
changeset 198:0b855758ba08
An additional TOML-related unittest (types)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 03 May 2019 22:26:06 +0200 |
| parents | 7865f28038a4 |
| children | 852f6c0c9298 |
| files | CHANGES.txt tests/data/conf1.toml tests/test.py |
| diffstat | 3 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Fri May 03 22:01:23 2019 +0200 +++ b/CHANGES.txt Fri May 03 22:26:06 2019 +0200 @@ -55,7 +55,8 @@ .. change:: :tags: feature - Handle TOML style configuration files also. + Added support for TOML style configuration files. This needs + the external package :py:mod:`toml` (from "uiri/toml"). .. changelog:: @@ -65,7 +66,7 @@ .. change:: :tags: breaking, feature - Reimplement :py:func:`configmix.safe_merge` do to a deepcopy of all + Reimplemented :py:func:`configmix.safe_merge` do to a deepcopy of all source configurations when merging. Previously is was sort of a shallow copy.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/data/conf1.toml Fri May 03 22:26:06 2019 +0200 @@ -0,0 +1,11 @@ +# -*- coding: utf-8; -*- + +__comment1 = "Comment 1" +key1 = "the value" +key2 = 2 +key3 = 5.7 +key4 = true +key5 = false +key6 = 0o377 +__comment2 = "Comment no 2" +key7 = "Umlaute: ÄÖÜäöüß"
--- a/tests/test.py Fri May 03 22:01:23 2019 +0200 +++ b/tests/test.py Fri May 03 22:26:06 2019 +0200 @@ -76,6 +76,11 @@ self.__check_types(cfg) self.__check_comment(cfg) + def test01_toml_types(self): + cfg = configmix.toml.load(os.path.join(TESTDATADIR, "conf1.toml")) + self.__check_types(cfg) + self.__check_comment(cfg) + def test02_py_types(self): cfg = configmix.py.load(os.path.join(TESTDATADIR, "conf1.py")) self.__check_types(cfg) @@ -274,7 +279,8 @@ cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), os.path.join(TESTDATADIR, "conf21.yml"), os.path.join(TESTDATADIR, "conf22.ini"), - os.path.join(TESTDATADIR, "conf23.json")) + os.path.join(TESTDATADIR, "conf23.json"), + os.path.join(TESTDATADIR, "conf24.toml")) def _c(name): def _f(): @@ -291,7 +297,8 @@ cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), os.path.join(TESTDATADIR, "conf21.yml"), os.path.join(TESTDATADIR, "conf22.ini"), - os.path.join(TESTDATADIR, "conf23.json")) + os.path.join(TESTDATADIR, "conf23.json"), + os.path.join(TESTDATADIR, "conf24.toml")) def _check(d): for k, v in d.items():
