示例#1
0
    def testSplitting(self):
        """Test of the internal splitting API."""
        # Try lots of keys that will return the same answer
        answer = ["a", "b", "c", "d"]
        self.assertSplit(answer, ".a.b.c.d", ":a:b:c:d", "\ta\tb\tc\td", "\ra\rb\rc\rd")

        answer = ["a", "calexp.wcs", "b"]
        self.assertSplit(answer, r".a.calexp\.wcs.b", ":a:calexp.wcs:b")

        self.assertSplit(["a.b.c"])
        self.assertSplit(["a", r"b\.c"], r"_a_b\.c")

        # Escaping a backslash before a delimiter currently fails
        with self.assertRaises(ValueError):
            Config._splitIntoKeys(r".a.calexp\\.wcs.b")

        # The next two fail because internally \r is magic when escaping
        # a delimiter.
        with self.assertRaises(ValueError):
            Config._splitIntoKeys("\ra\rcalexp\\\rwcs\rb")

        with self.assertRaises(ValueError):
            Config._splitIntoKeys(".a.cal\rexp\\.wcs.b")
示例#2
0
 def assertSplit(self, answer, *args):
     """Helper function to compare string splitting"""
     for s in (answer, *args):
         split = Config._splitIntoKeys(s)
         self.assertEqual(split, answer)