예제 #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, [])