Mercurial > hgrepos > Python > libs > ConfigMix
diff tests/test.py @ 448:b95c12781497
Attribute-style access for jailed configurations
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 11 Dec 2021 19:56:35 +0100 |
| parents | 94cf5a8722d6 |
| children | d6be95841380 |
line wrap: on
line diff
--- a/tests/test.py Fri Dec 10 12:00:24 2021 +0100 +++ b/tests/test.py Sat Dec 11 19:56:35 2021 +0100 @@ -1680,6 +1680,31 @@ self.assertTrue( jcfg.get([u"no", u"key"]) is None) + def test_attribute_access(self): + cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) + jcfg = cfg.jailed(rootpath=(u"tree1",)) + + self.assertEqual(0x20, jcfg.key3) + self.assertEqual(u"off", jcfg.tree2.key6) + + def test_attribute_access_non_existing(self): + cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) + jcfg = cfg.jailed(rootpath=(u"tree1",)) + + try: + jcfg.non_existing + except AttributeError: + pass + else: + self.fail("AttributeError expected") + + try: + jcfg.tree2.non_existing + except AttributeError: + pass + else: + self.fail("AttributeError expected") + if __name__ == "__main__": unittest.main()
