# HG changeset patch # User Franz Glasner # Date 1523692510 -7200 # Node ID bbf47bfb48a23b98f13f79cc7cda446295aaf029 # Parent d44ee758e31b25a6c22285724cd73643e62e7e9b Add a unittest that scans the complete configuration dict for comment keys diff -r d44ee758e31b -r bbf47bfb48a2 tests/test.py --- 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))