Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source-code/testing/Hypothesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ Run with pytest:
```bash
$ pytest --hypothesis-show-statistics
```

For the `points.py` example, run with:
```bash
$ pytest --hypothesis-show-statistics points.py
```
8 changes: 5 additions & 3 deletions source-code/testing/Hypothesis/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def test_distance():
assert math.isclose(p1.distance(p2), 5.0)


@given(x1=st.floats(), y1=st.floats(), x2=st.floats(), y2=st.floats(), x=st.floats(), y=st.floats())
def test_is_on_line(x1: float, y1: float, x2: float, y2: float, x: float, y: float):
@given(x1=st.floats(), y1=st.floats(), x2=st.floats(), y2=st.floats())
def test_is_on_line(x1: float, y1: float, x2: float, y2: float):
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p = Point(x, y)
p = Point((x1 + x2)/2, (y1 + y2)/2)
assert p.is_on_line(p1, p2)
assert p1.is_on_line(p1, p2)
assert p2.is_on_line(p1, p2)