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))
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)
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
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
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
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))
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))
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))
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
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)
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))
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)
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
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
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
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
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
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)
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)
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
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
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
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
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)
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
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)
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
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
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))
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
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
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)
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)
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)
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
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)
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
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)
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)
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