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}")
def test_unicode(self): match = gen_match(sre_parse.parse("•")) self.assertEqual(match, "•")
def test_lookahead(self): pattern = r"y(?=abc)" match = gen_match(sre_parse.parse(pattern)) self.assertRegex(match, pattern)
def test_noncapturing2(self): pattern = r"(?:abc){,3}" match = gen_match(sre_parse.parse(pattern)) self.assertRegex(match, pattern) print(match)
def test_oneof(self): match = gen_match(sre_parse.parse("[abc]abc")) self.assertIn(match, ["aabc", "babc", "cabc"])
def test_alternate2(self): pattern = r"(abc|\d+)" match = gen_match(sre_parse.parse(pattern)) self.assertRegex(match, pattern)
def test_alternate1(self): match = gen_match(sre_parse.parse("abc|def")) self.assertIn(match, ["abc", "def"])
def test_plain(self): match = gen_match(sre_parse.parse("abc")) self.assertEqual(match, "abc")