예제 #1
0
def test_group_ref_is_not_shared_between_identical_regex(data):
    pattern = re.compile(u"^(.+)\\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)
예제 #2
0
def test_group_ref_is_not_shared_between_identical_regex(data):
    pattern = re.compile(u"^(.+)\\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)
예제 #3
0
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
예제 #4
0
def test_does_not_leak_groups(data):
    a = data.draw(base_regex_strategy(re.compile(u"^(a)\\Z")))
    assert a == 'a'
    b = data.draw(base_regex_strategy(re.compile(u"^(?(1)a|b)(.)\\Z")))
    assert b[0] == 'b'
예제 #5
0
def test_does_not_leak_groups(data):
    a = data.draw(base_regex_strategy(re.compile(u"^(a)\\Z")))
    assert a == 'a'
    b = data.draw(base_regex_strategy(re.compile(u"^(?(1)a|b)(.)\\Z")))
    assert b[0] == 'b'
예제 #6
0
def test_conservative_regex_are_correct_by_construction(data):
    pattern = re.compile(data.draw(CONSERVATIVE_REGEX))
    pattern = re.compile(pattern)
    result = data.draw(base_regex_strategy(pattern))
    assert pattern.search(result) is not None