def test_point_distance_many_points(): for _ in range(1000): x = random.randint(-1e9, 1e9) y = random.randint(-1e9, 1e9) d = math.hypot(x, y) p = Point(x, y) assert p.x == x and p.y == y assert math.isclose(p.distance(), d)
def test_point_distance_other_point(): p = Point() q = Point(2, 0) assert p.distance(q) == 2
def test_point_distance_reflexive(): p = Point() q = Point(1, 1) assert p.distance(q) == q.distance(p)
def test_point_distance_to_self(): p = Point() assert p.distance(p) == 0