Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 432:b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 09 Dec 2021 22:51:10 +0100 |
| parents | 40be1d25ff1c |
| children | bbc5b64e137a |
comparison
equal
deleted
inserted
replaced
| 431:49cadb78c45a | 432:b96f49c9c76b |
|---|---|
| 15 import configmix.ini | 15 import configmix.ini |
| 16 import configmix.yaml | 16 import configmix.yaml |
| 17 import configmix.json | 17 import configmix.json |
| 18 import configmix.py | 18 import configmix.py |
| 19 import configmix.toml | 19 import configmix.toml |
| 20 from configmix.compat import u | 20 from configmix.compat import u, PY2 |
| 21 | 21 |
| 22 | 22 |
| 23 TESTDATADIR = os.path.join( | 23 TESTDATADIR = os.path.join( |
| 24 os.path.abspath(os.path.dirname(__file__)), | 24 os.path.abspath(os.path.dirname(__file__)), |
| 25 "data") | 25 "data") |
| 1533 | 1533 |
| 1534 self.assertEqual( | 1534 self.assertEqual( |
| 1535 set([u"key1", u"key2", u"tree1"]), | 1535 set([u"key1", u"key2", u"tree1"]), |
| 1536 set(jcfg.getkeys(u""))) | 1536 set(jcfg.getkeys(u""))) |
| 1537 | 1537 |
| 1538 def test_repr_empty_rootpath(self): | |
| 1539 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) | |
| 1540 jcfg = cfg.jailed(rootpath=tuple()) | |
| 1541 | |
| 1542 self.assertEqual( | |
| 1543 r"_JailedConfiguration(rootpath=())", | |
| 1544 repr(jcfg)) | |
| 1545 | |
| 1546 def test_repr_non_empty_rootpath(self): | |
| 1547 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) | |
| 1548 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) | |
| 1549 | |
| 1550 if PY2: | |
| 1551 self.assertEqual( | |
| 1552 r"_JailedConfiguration(rootpath=(u'tree1', u'tree2'))", | |
| 1553 repr(jcfg)) | |
| 1554 else: | |
| 1555 self.assertEqual( | |
| 1556 r"_JailedConfiguration(rootpath=('tree1', 'tree2'))", | |
| 1557 repr(jcfg)) | |
| 1558 | |
| 1538 | 1559 |
| 1539 if __name__ == "__main__": | 1560 if __name__ == "__main__": |
| 1540 unittest.main() | 1561 unittest.main() |
