示例#1
0
 def test_iterate_pattern_varaible_invalid_name(self):
     with self.assertRaises(ValueError):
         list(iterate_pattern("${ }"))
     with self.assertRaises(ValueError):
         list(iterate_pattern("${1A}"))
     with self.assertRaises(ValueError):
         list(iterate_pattern("${!}"))
示例#2
0
 def test_iterate_pattern_wildcards(self):
     results = list(iterate_pattern("one*?${var}*${s} two "))
     self.assertEquals(results,
                       ["one", "*", "?", "${var}", "*", "${s}", " two "])
     results = list(iterate_pattern("**?${var}middle*?"))
     self.assertEquals(results,
                       ["*", "*", "?", "${var}", "middle", "*", "?"])
示例#3
0
 def test_iterate_pattern_end_bracket(self):
     with self.assertRaises(ValueError):
         list(iterate_pattern("${value"))
     with self.assertRaises(ValueError):
         list(iterate_pattern("$"))
     with self.assertRaises(ValueError):
         list(iterate_pattern("}${"))
示例#4
0
 def test_iterate_pattern_escaped_literals(self):
     results = list(iterate_pattern("${?}${*}${$}"))
     self.assertEquals(results, ["${?}", "${*}", "${$}"])
示例#5
0
 def test_iterate_pattern_varaible_empty_name(self):
     with self.assertRaises(ValueError):
         list(iterate_pattern("${}"))
示例#6
0
 def test_iterate_pattern_start_bracket(self):
     with self.assertRaises(ValueError):
         list(iterate_pattern("$ {value}"))
     with self.assertRaises(ValueError):
         list(iterate_pattern("$}{"))
示例#7
0
 def test_iterate_pattern_literal(self):
     result = list(iterate_pattern(" "))
     self.assertEqual(result, [" "])
     result = list(iterate_pattern("1234-56 78.90"))
     self.assertEqual(result, ["1234-56 78.90"])
示例#8
0
 def test_iterate_pattern_empty_pattern(self):
     result = list(iterate_pattern(""))
     self.assertEqual(result, [])