-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: initial commit adding hypothesis property testing library
Adding the Hypothesis cache dir to .gitignore Grammar fixes in geometry.py Hypothesis dep in pyproject.toml without version peg Initial strategies in conftest.py. This is the only file name I could use that didn't cause an issue with the name-tests-test pre-commit hook. 'strategies.py' would be better because strictly speaking these aren't fixtures. An example test for encode/decode invariance.
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 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 |
---|---|---|
|
@@ -24,3 +24,4 @@ venv/ | |
__pycache__/ | ||
*.stderr* | ||
docs/_* | ||
.hypothesis/ |
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
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 |
---|---|---|
|
@@ -79,6 +79,7 @@ linting = [ | |
"yamllint", | ||
] | ||
tests = [ | ||
"hypothesis", | ||
"pytest", | ||
"pytest-cov", | ||
] | ||
|
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Data-generating strategies for property-based testing.""" | ||
import hypothesis.strategies as st | ||
|
||
# Incomplete list of allowed spatial reference systems to generate data | ||
# - EPSG 4326 | ||
# - EPSG 3857 | ||
# ...? | ||
|
||
|
||
# EPSG:4326 primitives | ||
latitudes = st.floats( | ||
min_value=-90.0, | ||
max_value=90.0, | ||
allow_nan=False, | ||
allow_infinity=False, | ||
) | ||
longitudes = st.floats( | ||
min_value=-180.0, | ||
max_value=180.0, | ||
allow_nan=False, | ||
allow_infinity=False, | ||
) | ||
elevations = st.floats(allow_nan=False, allow_infinity=False) | ||
|
||
|
||
# Point2D | ||
@st.composite | ||
def points_2d(draw, srs="EPSG:4326"): | ||
if srs == "EPSG:4326": | ||
return draw(st.tuples(latitudes, longitudes)) | ||
raise NotImplementedError | ||
|
||
|
||
# Point3D | ||
@st.composite | ||
def points_3d(draw, srs="EPSG:4326"): | ||
if srs == "EPSG:4326": | ||
return draw(st.tuples(latitudes, longitudes, elevations)) | ||
raise NotImplementedError | ||
|
||
|
||
# PointType | ||
@st.composite | ||
def points(draw, srs="EPSG:4326"): | ||
if srs == "EPSG:4326": | ||
return draw(st.one_of(points_2d(), points_3d())) | ||
raise NotImplementedError | ||
|
||
|
||
# LineType | ||
|
||
# Geometries |
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