示例#1
0
def test_street_number_positive(input, expected):
    ''' tests positive exact string match for a street number '''
    match = utils.match(data_ca.street_number, input, re.VERBOSE)
    is_found = match is not None
    # check for exact match
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
示例#2
0
def execute_matching_test(input, expected, pattern):
    match = utils.match(pattern, input, re.VERBOSE)
    is_found = match is not None
    if expected:
        assert is_found == expected and match.group(0) == input
    else:
        assert (is_found == expected) or (match.group(0) != input)
示例#3
0
def test_street_type(input, expected):
    ''' tests string match for a street id '''
    is_found = utils.match(
        data_ca.street_type,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
示例#4
0
def test_building(input, expected):
    ''' tests string match for a building '''
    is_found = utils.match(
        data_ca.building,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
示例#5
0
def test_floor(input, expected):
    ''' tests string match for a floor '''
    is_found = utils.match(
        data_ca.floor,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
示例#6
0
def test_occupancy_positive(input, expected):
    ''' tests exact string match for a place id '''
    match = utils.match(data_ca.occupancy, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
示例#7
0
def test_full_address_positive(input, expected):
    ''' tests exact string match for a full address '''
    match = utils.match(data_ca.full_address, utils.unicode_str(input),
                        re.VERBOSE | re.U)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
示例#8
0
def test_postal_code_negative(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_ca.postal_code, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) or\
           (match.group(0) != utils.unicode_str(input))
示例#9
0
def test_post_direction(input, expected):
    ''' tests string match for a post_direction '''
    is_found = utils.match(
        data_ca.post_direction,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
示例#10
0
def test_street_name_negative(input, expected):
    ''' tests positive string match for a street name '''
    match = utils.match(data_us.street_number, input, re.VERBOSE)
    is_found = match is not None
    """we check that:
       - input should not to match our regex
       - our match should be partial if regex matches some part of string
    """
    assert (is_found == expected) or (match.group(0) != input)
示例#11
0
def test_street_number_negative(input, expected):
    ''' tests negative string match for a street number '''
    match = utils.match(data_ca.street_number, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    """we check that:
       - input should not to match our regex
       - our match should be partial if regex matches some part of string
    """
    assert (is_found == expected) or \
           (match.group(0) != utils.unicode_str(input))
示例#12
0
def execute_matching_test(input, expected, pattern):
    match = utils.match(pattern, input, re.VERBOSE)
    is_found = match is not None
    if expected:
        assert is_found == expected and match.group(0) == input
    else:
        """we check that:
           - input should not to match our regex
           - our match should be partial if regex matches some part of string
        """
        assert (is_found == expected) or (match.group(0) != input)
示例#13
0
def test_zero_to_nine(input, expected):
    ''' test string match for zero_to_nine '''
    is_found = utils.match(data_us.zero_to_nine, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#14
0
def test_full_address_negative(input, expected):
    ''' tests string match for a full address '''
    match = utils.match(data_us.full_address, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected
示例#15
0
def test_hundred(input, expected):
    ''' tests string match for a hundred '''
    is_found = utils.match(data_ca.hundred, input, re.VERBOSE) is not None
    assert is_found == expected
示例#16
0
def test_country(input, expected):
    ''' test exact string match for country '''
    match = utils.match(data_ca.country, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
示例#17
0
def test_floor(input, expected):
    ''' tests string match for a floor '''
    is_found = utils.match(data_us.floor, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#18
0
def test_po_box_negative(input, expected):
    ''' tests string match for a po box '''
    match = utils.match(data_ca.po_box, utils.unicode_str(input), re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
示例#19
0
def test_occupancy_negative(input, expected):
    ''' tests string match for a place id '''
    match = utils.match(data_ca.occupancy, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
示例#20
0
def test_hundred(input, expected):
    ''' tests string match for a hundred '''
    is_found = utils.match(data_us.hundred, input, re.VERBOSE) is not None
    assert is_found == expected
示例#21
0
def test_country(input, expected):
    ''' test exact string match for country '''
    match = utils.match(data_us.country, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
示例#22
0
def test_region1(input, expected):
    ''' test exact string match for province '''
    match = utils.match(data_us.region1, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
示例#23
0
def test_ten_to_ninety(input, expected):
    ''' test string match for ten_to_ninety '''
    is_found = utils.match(data_us.ten_to_ninety, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#24
0
def test_postal_code_negative(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_us.postal_code, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) or (match.group(0) != input)
示例#25
0
def test_postal_code_positive(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_us.postal_code, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
示例#26
0
def test_occupancy_positive(input, expected):
    ''' tests exact string match for a place id '''
    match = utils.match(data_us.occupancy, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
示例#27
0
def test_zero_to_nine(input, expected):
    ''' test string match for zero_to_nine '''
    is_found = utils.match(data_ca.zero_to_nine, input, re.VERBOSE) is not None
    assert is_found == expected
示例#28
0
def test_thousand(input, expected):
    ''' tests string match for a thousand '''
    is_found = utils.match(data_us.thousand, input, re.VERBOSE) is not None
    assert is_found == expected
示例#29
0
def test_po_box_positive(input, expected):
    ''' tests exact string match for a po box '''
    match = utils.match(data_ca.po_box, utils.unicode_str(input), re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
示例#30
0
def test_street_type(input, expected):
    ''' tests string match for a street id '''
    is_found = utils.match(data_us.street_type, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#31
0
def test_building(input, expected):
    ''' tests string match for a building '''
    is_found = utils.match(data_us.building, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#32
0
def test_po_box_negative(input, expected):
    ''' tests string match for a po box '''
    match = utils.match(data_us.po_box, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
示例#33
0
def test_region1(input, expected):
    ''' test exact string match for province '''
    match = utils.match(data_ca.region1, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and \
        match.group(0) == utils.unicode_str(input)
示例#34
0
def test_po_box_positive(input, expected):
    ''' tests exact string match for a po box '''
    match = utils.match(data_us.po_box, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
示例#35
0
def test_ten_to_ninety(input, expected):
    ''' test string match for ten_to_ninety '''
    is_found = utils.match(data_ca.ten_to_ninety, input, re.VERBOSE)\
        is not None
    assert is_found == expected
示例#36
0
def test_occupancy_negative(input, expected):
    ''' tests string match for a place id '''
    match = utils.match(data_us.occupancy, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
示例#37
0
def test_thousand(input, expected):
    ''' tests string match for a thousand '''
    is_found = utils.match(data_ca.thousand, input, re.VERBOSE) is not None
    assert is_found == expected
示例#38
0
def test_full_address_positive(input, expected):
    ''' tests exact string match for a full address '''
    match = utils.match(data_us.full_address, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
示例#39
0
def test_street_number_positive(input, expected):
    ''' tests positive exact string match for a street number '''
    match = utils.match(data_us.street_number, input, re.VERBOSE)
    is_found = match is not None
    # check for exact match
    assert (is_found == expected) and (match.group(0) == input)
示例#40
0
def test_post_direction(input, expected):
    ''' tests string match for a post_direction '''
    is_found = utils.match(data_us.post_direction, input, re.VERBOSE)\
        is not None
    assert is_found == expected