Пример #1
0
 def test_pattern_to_regex_escaped_literals(self):
     result = pattern_to_regex("${*}")
     self.assertEquals(result, "\*")
     result = pattern_to_regex("${?}")
     self.assertEquals(result, "\?")
     result = pattern_to_regex("${$}")
     self.assertEquals(result, "\$")
Пример #2
0
 def test_pattern_to_regex_varaible_invalid_name(self):
     with self.assertRaises(ValueError):
         pattern_to_regex("${ }")
     with self.assertRaises(ValueError):
         pattern_to_regex("${1A}")
     with self.assertRaises(ValueError):
         pattern_to_regex("${!}")
Пример #3
0
 def test_pattern_to_regex_invalid_end_bracket(self):
     with self.assertRaises(ValueError):
         pattern_to_regex("${value")
     with self.assertRaises(ValueError):
         pattern_to_regex("$")
     with self.assertRaises(ValueError):
         pattern_to_regex("}${")
Пример #4
0
 def test_pattern_to_regex_empty_pattern(self):
     result = pattern_to_regex("")
     self.assertEqual(result, "")
Пример #5
0
 def test_pattern_to_regex_variable(self):
     result = pattern_to_regex("${variablename}")
     self.assertEquals(result, "(?P<variablename>.*)")
     result = pattern_to_regex("${variablename}", "^:")
     self.assertEquals(result, "(?P<variablename>^:*)")
Пример #6
0
 def test_pattern_to_regex_wildcard_single(self):
     result = pattern_to_regex("?")
     self.assertEquals(result, ".")
     result = pattern_to_regex("?", "^:")
     self.assertEquals(result, "^:")
Пример #7
0
 def test_pattern_to_regex_wildcard_multiple(self):
     result = pattern_to_regex("*")
     self.assertEquals(result, ".*")
     result = pattern_to_regex("*", "^:")
     self.assertEquals(result, "^:*")
Пример #8
0
 def test_pattern_to_regex_literals(self):
     result = pattern_to_regex(".+-")
     self.assertEquals(result, "\.\+\-")
Пример #9
0
 def test_pattern_to_regex_varaible_empty_name(self):
     with self.assertRaises(ValueError):
         pattern_to_regex("${}")
Пример #10
0
 def test_pattern_to_regex_invalid_start_bracket(self):
     with self.assertRaises(ValueError):
         pattern_to_regex("$ {value}")
     with self.assertRaises(ValueError):
         pattern_to_regex("$}{")