Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 552:39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
This is needed as precondition for implementation interpolate_variables in
C also.
Currently the speedup is not measurable but it does not hurt also.
Also provide some unit-tests for _split_filters().
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 02 Jan 2022 20:40:09 +0100 |
| parents | 79db28e879f8 |
| children | 9d2bd411f5c5 |
comparison
equal
deleted
inserted
replaced
| 551:4c968c5cfce6 | 552:39e5d07d8dbc |
|---|---|
| 1901 self.split_ns(u"the-ns:the-rest:with:colons|filter1|filter2")) | 1901 self.split_ns(u"the-ns:the-rest:with:colons|filter1|filter2")) |
| 1902 | 1902 |
| 1903 def test_split_ns_quoting(self): | 1903 def test_split_ns_quoting(self): |
| 1904 self.assertEqual((u":", u"%x3a"), self.split_ns(u"%x3a:%x3a")) | 1904 self.assertEqual((u":", u"%x3a"), self.split_ns(u"%x3a:%x3a")) |
| 1905 | 1905 |
| 1906 def test_split_filters_empty(self): | |
| 1907 self.assertEqual((u"", []), self.split_filters(u"")) | |
| 1908 | |
| 1909 def test_split_filters_varname_only(self): | |
| 1910 self.assertEqual((u"varname ", []), self.split_filters(u"varname ")) | |
| 1911 | |
| 1912 def test_split_filters_single_stripping(self): | |
| 1913 self.assertEqual((u" the-varname", []), | |
| 1914 self.split_filters(u" the-varname | ")) | |
| 1915 | |
| 1916 def test_split_filters_one(self): | |
| 1917 self.assertEqual((u"the-varname", [u"None"]), | |
| 1918 self.split_filters(u"the-varname |None")) | |
| 1919 | |
| 1920 def test_split_filters_many(self): | |
| 1921 self.assertEqual((u"the-varname", [u"Empty", u"None"]), | |
| 1922 self.split_filters(u"the-varname |Empty|None")) | |
| 1923 | |
| 1906 | 1924 |
| 1907 class T09Parser(_TParserMixin, unittest.TestCase): | 1925 class T09Parser(_TParserMixin, unittest.TestCase): |
| 1908 | 1926 |
| 1909 def setUp(self): | 1927 def setUp(self): |
| 1910 self.unquote = configmix.config.py_unquote | 1928 self.unquote = configmix.config.py_unquote |
| 1911 self.quote = configmix.config.py_quote | 1929 self.quote = configmix.config.py_quote |
| 1912 self.pathstr2path = configmix.config.py_pathstr2path | 1930 self.pathstr2path = configmix.config.py_pathstr2path |
| 1913 self.split_ns = configmix.config._py_split_ns | 1931 self.split_ns = configmix.config._py_split_ns |
| 1932 self.split_filters = configmix.config._py_split_filters | |
| 1914 | 1933 |
| 1915 def test_split_ns_wrong_type(self): | 1934 def test_split_ns_wrong_type(self): |
| 1916 self.assertRaises( | 1935 self.assertRaises( |
| 1917 AttributeError, # no .partition | 1936 AttributeError, # no .partition |
| 1918 self.split_ns, | 1937 self.split_ns, |
| 1937 def setUp(self): | 1956 def setUp(self): |
| 1938 self.unquote = configmix.config.fast_unquote | 1957 self.unquote = configmix.config.fast_unquote |
| 1939 self.quote = configmix.config.fast_quote | 1958 self.quote = configmix.config.fast_quote |
| 1940 self.pathstr2path = configmix.config.fast_pathstr2path | 1959 self.pathstr2path = configmix.config.fast_pathstr2path |
| 1941 self.split_ns = configmix.config._fast_split_ns | 1960 self.split_ns = configmix.config._fast_split_ns |
| 1961 self.split_filters = configmix.config._fast_split_filters | |
| 1942 | 1962 |
| 1943 def test_split_ns_wrong_type(self): | 1963 def test_split_ns_wrong_type(self): |
| 1944 self.assertRaises( | 1964 self.assertRaises( |
| 1945 TypeError, | 1965 TypeError, |
| 1946 self.split_ns, | 1966 self.split_ns, |
