# HG changeset patch # User Franz Glasner # Date 1637322023 -3600 # Node ID 6a5aea02f3d0b4525fba436a1b5bd526a2e2e966 # Parent 7db59202c9afcd65708848e91c52de480580e35b Implement a ".is_jail" flag for configuration objects: to test/assert whether we expect a jail configuration diff -r 7db59202c9af -r 6a5aea02f3d0 configmix/config.py --- a/configmix/config.py Fri Nov 19 09:31:26 2021 +0100 +++ b/configmix/config.py Fri Nov 19 12:40:23 2021 +0100 @@ -73,6 +73,9 @@ _QUOTE = u(b'%') _COMMENT = u(b'#') + is_jail = False + """Flag to show that this is not a jail for another configuration""" + def getvarl(self, *path, **kwds): """Get a variable where the hierarchy is given in `path` as sequence and the namespace is given in the `namespace` keyword argument. @@ -708,6 +711,9 @@ __slots__ = ("_base", "_path", "_pathstr") + is_jail = True + """Flag to show that this is a jail for another configuration""" + def __init__(self, config, *path): super(_JailedConfiguration, self).__init__() self._base = config diff -r 7db59202c9af -r 6a5aea02f3d0 tests/test.py --- a/tests/test.py Fri Nov 19 09:31:26 2021 +0100 +++ b/tests/test.py Fri Nov 19 12:40:23 2021 +0100 @@ -1172,7 +1172,10 @@ def test_root(self): cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) + self.assertFalse(cfg.is_jail) + jcfg = cfg.jailed(root=u"tree1") + self.assertTrue(jcfg.is_jail) self.assertTrue(jcfg.getvarl(u"tree2", u"key5")) self.assertTrue(jcfg.getvarl_s(u"tree2", u"key5"))