Mercurial > hgrepos > Python > libs > ConfigMix
changeset 329:d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
BUGS: The "ref" namespace is handled specially and not yet compatible with
escaping some character of the "ref:" marker.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 07 May 2021 09:18:41 +0200 |
| parents | cffa4fcd0a4d |
| children | cbef412c841d |
| files | configmix/config.py tests/test.py |
| diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/configmix/config.py Thu May 06 22:58:10 2021 +0200 +++ b/configmix/config.py Fri May 07 09:18:41 2021 +0200 @@ -237,7 +237,7 @@ if len(nameparts) == 1: return (None, s, ) else: - return (nameparts[0], nameparts[1], ) + return (self.unquote(nameparts[0]), nameparts[1], ) def _split_filters(self, s): nameparts = s.split(self._FILTER_SEPARATOR)
--- a/tests/test.py Thu May 06 22:58:10 2021 +0200 +++ b/tests/test.py Fri May 07 09:18:41 2021 +0200 @@ -785,6 +785,14 @@ for c in """abc09'"#:|%./""": self.assertEqual(c, self._cfg.unquote(self._cfg.quote(c))) + def test_namespace_quoting(self): + v1 = self._cfg.getvar("PY:version") + v2 = self._cfg.getvar("P%x59:version") + v3 = self._cfg.getvar("%x50Y:version") + v4 = self._cfg.getvar("%x50%x59:version") + self.assertEqual(v1, v2) + self.assertEqual(v1, v3) + self.assertEqual(v1, v4) if __name__ == "__main__": unittest.main()
