Exemplo n.º 1
0
 def test_notoneof(self):
   match = gen_match(sre_parse.parse("[^abc]def"))
   if len(match) != 4:
     raise AssertionError(f"Unexpected generated match {match}")
   if not match.endswith("def"):
     raise AssertionError(f"Unexpected generated match {match}")
   if match[0] in "abc":
     raise AssertionError(f"Unexpected generated match {match}")
Exemplo n.º 2
0
 def test_unicode(self):
   match = gen_match(sre_parse.parse("•"))
   self.assertEqual(match, "•")
Exemplo n.º 3
0
 def test_lookahead(self):
   pattern = r"y(?=abc)"
   match = gen_match(sre_parse.parse(pattern))
   self.assertRegex(match, pattern)
Exemplo n.º 4
0
 def test_noncapturing2(self):
   pattern = r"(?:abc){,3}"
   match = gen_match(sre_parse.parse(pattern))
   self.assertRegex(match, pattern)
   print(match)
Exemplo n.º 5
0
 def test_oneof(self):
   match = gen_match(sre_parse.parse("[abc]abc"))
   self.assertIn(match, ["aabc", "babc", "cabc"])
Exemplo n.º 6
0
 def test_alternate2(self):
   pattern = r"(abc|\d+)"
   match = gen_match(sre_parse.parse(pattern))
   self.assertRegex(match, pattern)
Exemplo n.º 7
0
 def test_alternate1(self):
   match = gen_match(sre_parse.parse("abc|def"))
   self.assertIn(match, ["abc", "def"])
Exemplo n.º 8
0
 def test_plain(self):
   match = gen_match(sre_parse.parse("abc"))
   self.assertEqual(match, "abc")