def test_point_at(): """Check point_at is correct.""" s = LineSegment(Point(0, 0, 'A'), Point(1, 1, 'B')) with pytest.raises(TypeError) as excinfo: s.point_at('a') assert str(excinfo.value) == 'position must be a number, found ' \ '<class \'str\'> instead.' assert s.point_at(Number('0.5')) == s.midpoint() assert s.point_at(Number('0.75')) == Point('0.75', '0.75') assert s.point_at(Number(2)) == Point(2, 2) assert s.point_at(0) == Point(0, 0) assert s.point_at(1) == Point(1, 1) assert s.point_at(-2) == Point(-2, -2) s = LineSegment(Point(1, 1, 'A'), Point(3, 4, 'B')) assert s.point_at(Number('0.8')) == Point('2.6', '3.4') assert s.point_at(2) == Point(5, 7) assert s.point_at(Number('0.5')) == s.midpoint()
def test_midpoint(): """Check midpoint is correct.""" s = LineSegment(Point(0, 0, 'A'), Point(1, 1, 'B')) assert s.midpoint() == Point(Number('0.5'), Number('0.5'))