Mercurial > hgrepos > Python > libs > ConfigMix
changeset 146:bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sat, 14 Apr 2018 09:55:10 +0200 |
| parents | d44ee758e31b |
| children | 8b7333caba25 |
| files | tests/test.py |
| diffstat | 1 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test.py Fri Apr 13 21:44:42 2018 +0200 +++ b/tests/test.py Sat Apr 14 09:55:10 2018 +0200 @@ -255,18 +255,32 @@ self.assertRaises(KeyError, _c("db.__comment1")) self.assertRaises(KeyError, _c("db.user.__doc2")) + def test06_check_all_comments(self): + 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")) + + def _check(d): + for k, v in d.items(): + self.assertFalse(configmix._is_comment(k)) + if isinstance(v, dict): + _check(v) + + _check(cfg) + class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): def setUp(self): self._load = configmix.load - def test06_identity(self): + def test07_identity(self): cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) cfg2 = configmix.merge(cfg, None) self.assertEqual(id(cfg), id(cfg2)) - def test07_identity(self): + def test08_identity(self): cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) cfg2 = configmix.merge(cfg, {}) self.assertEqual(id(cfg), id(cfg2)) @@ -277,12 +291,12 @@ def setUp(self): self._load = configmix.safe_load - def test06_deepcopy(self): + def test07_deepcopy(self): cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) cfg2 = configmix.safe_merge(cfg, None) self.assertNotEqual(id(cfg), id(cfg2)) - def test07_deepcopy(self): + def test08_deepcopy(self): cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) cfg2 = configmix.safe_merge(cfg, {}) self.assertNotEqual(id(cfg), id(cfg2))
