def test_parse_coordinate_as_dms(test_input, kind, expected): coord = parse_coordinate(test_input, kind)[0] degrees, minutes, seconds, hemisphere = expected assert coord.degrees == degrees assert coord.minutes == minutes assert coord.seconds == seconds assert coord.hemisphere == hemisphere
def test_delimited_input(): coords = parse_coordinate('40 N; 45 N; 50 N', 'latitude') assert [str(c) for c in coords] == ['40 N', '45 N', '50 N']
def test_sixties(test_input, expected): assert str(parse_coordinate(test_input, 'latitude')[0]) == expected
def test_invalid_input(test_input): with pytest.raises(TypeError): parse_coordinate(test_input, 'latitude')
def test_out_of_bounds_coordinates(test_input, kind): with pytest.raises(ValueError): parse_coordinate(test_input, kind)
def test_estimate_precision(test_input, expected): coord = parse_coordinate(test_input, 'latitude')[0] assert coord.estimate_precision() == approx(expected, rel=1e-2)
def test_coordinate_str(test_input, kind, expected): coord = parse_coordinate(test_input, kind)[0] assert str(parse_coordinate(test_input, kind)[0]) == expected
def test_parse_coordinate_as_decimal(test_input, kind, expected): coord = parse_coordinate(test_input, kind)[0] assert coord.decimal == approx(expected, rel=1e-2)
def test_illegal_dms_with_decimals(): with pytest.raises(ValueError): parse_coordinate('45 30.5 30 N', 'latitude')
def test_dms_with_decimals(test_input, expected): assert str(parse_coordinate(test_input, 'latitude')[0]) == expected
def test_is_decimal(): assert not parse_coordinate('45 0 0 N', 'latitude')[0].is_decimal() assert parse_coordinate(45, 'latitude')[0].is_decimal()