Esempio n. 1
0
def test_regex_validate_pattern_list_patterns_fails():
    p = [r'\d{3}', r'[a-z]{100}']
    f = Regex(pattern=p)
    for value in ('not_a_number', 'other12thing'):
        with pytest.raises(FieldSet.Error):
            f._validate_pattern(p, value)
Esempio n. 2
0
def test_regex_validate_pattern_list_patterns():
    p = [r'\d{1,3}', r'[a-z]{2,3}']
    f = Regex(pattern=p)
    for value in ('100', '0', 'te', 'tes'):
        assert f._validate_pattern(p, value)[0] == value
Esempio n. 3
0
def test_regex_validate_pattern_fail():
    p = r'\d{3}'
    f = Regex(pattern=p)
    for value in ('not_a_number', 'other12thing'):
        with pytest.raises(FieldSet.Error):
            f._validate_pattern(value, p)
Esempio n. 4
0
def test_regex_validate_pattern():
    p = r'\d{1,3}'
    f = Regex(pattern=p)
    for value in ('123', '0', '10'):
        assert f._validate_pattern(p, value)[0] == value
Esempio n. 5
0
def test_regex_validate_pattern_use_first_found():
    p = r'\d{1,3}'
    f = Regex(use_first_found=True, pattern=p)
    for value in ('123', '0', '10'):
        assert f._validate_pattern(p, value) == value
Esempio n. 6
0
def test_regex_validate_pattern_list_patterns_fails():
    p = [r'\d{3}', r'[a-z]{100}']
    f = Regex(pattern=p)
    for value in ('not_a_number', 'other12thing'):
        with pytest.raises(FieldSet.Error):
            f._validate_pattern(p, value)
Esempio n. 7
0
def test_regex_validate_pattern_fail():
    p = r'\d{3}'
    f = Regex(pattern=p)
    for value in ('not_a_number', 'other12thing'):
        with pytest.raises(FieldSet.Error):
            f._validate_pattern(value, p)
Esempio n. 8
0
def test_regex_validate_pattern_list_patterns():
    p = [r'\d{1,3}', r'[a-z]{2,3}']
    f = Regex(pattern=p)
    for value in ('100', '0', 'te', 'tes'):
        assert f._validate_pattern(p, value)[0] == value
Esempio n. 9
0
def test_regex_validate_pattern_use_first_found():
    p = r'\d{1,3}'
    f = Regex(use_first_found=True, pattern=p)
    for value in ('123', '0', '10'):
        assert f._validate_pattern(p, value) == value
Esempio n. 10
0
def test_regex_validate_pattern():
    p = r'\d{1,3}'
    f = Regex(pattern=p)
    for value in ('123', '0', '10'):
        assert f._validate_pattern(p, value)[0] == value