File: test_format.py

package info (click to toggle)
geopy 2.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 928 kB
  • sloc: python: 10,243; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest

from geopy.format import format_degrees
from geopy.point import Point


@pytest.mark.parametrize(
    "input, expected",
    [
        (("12", "30", 0), "12 30' 0\""),
        (("12", "30", "30"), "12 30' 30\""),
        (("12", "30", 30.4), "12 30' 30.4\""),
    ],
)
def test_format_simple(input, expected):
    assert format_degrees(Point.parse_degrees(*input)) == expected


# These tests currently fail, because conversion to degrees (as float)
# causes loss in precision (mostly because of divisions by 3):
@pytest.mark.xfail
@pytest.mark.parametrize(
    "input, expected",
    [
        (("13", "20", 0), "13 20' 0\""),  # actual: `13 20' 2.13163e-12"`
        (("-13", "19", 0), "-13 19' 0\""),  # actual: `-13 18' 60"`
    ],
)
def test_format_float_precision(input, expected):
    assert format_degrees(Point.parse_degrees(*input)) == expected