Mercurial > hgrepos > Python > libs > ConfigMix
diff tests/test.py @ 543:491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 01 Jan 2022 18:01:32 +0100 |
| parents | f71d34dda19f |
| children | 79db28e879f8 |
line wrap: on
line diff
--- a/tests/test.py Fri Dec 31 21:24:16 2021 +0100 +++ b/tests/test.py Sat Jan 01 18:01:32 2022 +0100 @@ -1777,7 +1777,7 @@ e = configmix.quote(u"") self.assertEqual(u"", e) self.assertEqual(u"", self.unquote(e)) - + def test_quoting_and_unquoting_are_inverse(self): for c in u"""%.:#|"'{}[]""": qc = configmix.quote(c) @@ -1874,12 +1874,36 @@ p = self.pathstr2path(u"a%x2Eb.c%u002Ed.e%U0000002Ef") self.assertEqual((u"a.b", u"c.d", u"e.f"), p) + def test_split_ns_empty(self): + self.assertEqual((None, u""), self.split_ns(u"")) + + def test_split_ns_empty_parts(self): + self.assertEqual((u"", u""), self.split_ns(u":")) + + def test_split_ns_no_ns(self): + self.assertEqual((None, u"the-varname"), self.split_ns(u"the-varname")) + + def test_split_ns_non_quoted(self): + self.assertEqual( + (u"the-ns", "the-rest:with:colons|filter1|filter2"), + self.split_ns(u"the-ns:the-rest:with:colons|filter1|filter2")) + + def test_split_ns_quoting(self): + self.assertEqual((u":", u"%x3a"), self.split_ns(u"%x3a:%x3a")) + class T09Parser(_TParserMixin, unittest.TestCase): def setUp(self): self.unquote = configmix.config.py_unquote self.pathstr2path = configmix.config.py_pathstr2path + self.split_ns = configmix.config._py_split_ns + + def test_split_ns_wrong_type(self): + self.assertRaises( + AttributeError, # no .partition + self.split_ns, + 1) if configmix.config.fast_unquote is not None: @@ -1888,6 +1912,13 @@ def setUp(self): self.unquote = configmix.config.fast_unquote self.pathstr2path = configmix.config.fast_pathstr2path + self.split_ns = configmix.config._fast_split_ns + + def test_split_ns_wrong_type(self): + self.assertRaises( + TypeError, + self.split_ns, + b":") if __name__ == "__main__":
