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("${!}"))
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", "*", "?"])
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("}${"))
def test_iterate_pattern_escaped_literals(self): results = list(iterate_pattern("${?}${*}${$}")) self.assertEquals(results, ["${?}", "${*}", "${$}"])
def test_iterate_pattern_varaible_empty_name(self): with self.assertRaises(ValueError): list(iterate_pattern("${}"))
def test_iterate_pattern_start_bracket(self): with self.assertRaises(ValueError): list(iterate_pattern("$ {value}")) with self.assertRaises(ValueError): list(iterate_pattern("$}{"))
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"])
def test_iterate_pattern_empty_pattern(self): result = list(iterate_pattern("")) self.assertEqual(result, [])