def test_can_get_correct_intersection(self, test_segment1, test_segment2, expected): segment1 = systems.WireSegment(*test_segment1) segment2 = systems.WireSegment(*test_segment2) ret_val = segment1.intersects_at(segment2) assert ret_val == expected
def test_init_raises_exception_with_both_coordinates_same(self): with pytest.raises(ValueError): segment = systems.WireSegment((1, 1), (1, 1))
def test_can_get_correct_orientation(self, test_input, expected): segment = systems.WireSegment(*test_input) assert segment.orientation == expected
def test_init_raises_exception_with_bad_input(self): with pytest.raises(ValueError): segment = systems.WireSegment((0, "apple"), (0, 1)) with pytest.raises(ValueError): segment = systems.WireSegment((0, 1), (0, "apple"))
def test_init(self): segment = systems.WireSegment((0, 0), (0, 1)) assert segment.start == (0, 0) assert segment.end == (0, 1)
def test_can_call_intersects_point(self, test_segment, test_point, expected): segment = systems.WireSegment(*test_segment) assert segment.intersects_point(test_point) == expected
def test_can_get_correct_length(self, test_segment, expected): segment = systems.WireSegment(*test_segment) assert segment.length == expected
def test_intersects_at_raises_exception_with_bad_input(self, test_segment): segment = systems.WireSegment(*test_segment) with pytest.raises(TypeError): segment.intersects_at("bad input")