-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,20 +251,18 @@ def test_line_point_from_start(p1, p2): | |
([-11.1, 22.2, 33.3], [1.1, -2.2, -3.3]), | ||
], | ||
) | ||
@pytest.mark.parametrize( | ||
"distance", | ||
[0, 1, 4, -9, 3.3, 0.00001, -0.00001], | ||
) | ||
def test_line_point_from_end(p1, p2, distance): | ||
line = Line(p1, p2) | ||
point = line.point_from_end(distance) | ||
distance_to_start = distance_point_point(point, p1) | ||
distance_to_end = distance_point_point(point, p2) | ||
# Check that the distance is correct | ||
assert TOL.is_close(distance_to_end, abs(distance)) | ||
# Check that negative distance gives a point far away from start | ||
if distance < 0: | ||
assert distance_to_start > line.length | ||
distances = [0, 1, 4, -9, 3.3, 0.00001, -0.00001] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yck011522
Author
Contributor
|
||
for distance in distances: | ||
line = Line(p1, p2) | ||
point = line.point_from_end(distance) | ||
distance_to_start = distance_point_point(point, p1) | ||
distance_to_end = distance_point_point(point, p2) | ||
# Check that the distance is correct | ||
assert TOL.is_close(distance_to_end, abs(distance)) | ||
# Check that negative distance gives a point far away from start | ||
if distance < 0: | ||
assert distance_to_start > line.length | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
you could still use
pytest.mark.parametrize
, but the problem here was that the param list didn't match, right?p1
andp2
were missing in the parametrization