def test_group_ref_is_not_shared_between_identical_regex(data): pattern = re.compile("^(.+)\\1\\Z", re.UNICODE) x = data.draw(base_regex_strategy(pattern)) y = data.draw(base_regex_strategy(pattern)) assume(x != y) assert pattern.match(x).end() == len(x) assert pattern.match(y).end() == len(y)
def test_conservative_regex_are_correct_by_construction(data): pattern = re.compile(data.draw(CONSERVATIVE_REGEX), flags=data.draw(FLAGS)) result = data.draw(base_regex_strategy(pattern)) assert pattern.search(result) is not None
def test_does_not_leak_groups(data): a = data.draw(base_regex_strategy(re.compile("^(a)\\Z"))) assert a == "a" b = data.draw(base_regex_strategy(re.compile("^(?(1)a|b)(.)\\Z"))) assert b[0] == "b"