Skip to content

Commit

Permalink
Add hypothesis profile for continuous integration (CI) testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed May 1, 2024
1 parent 17e1d72 commit 9c2063c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
python -m pip install -e ".[tests]"
- name: Test with pytest including hypothesis tests
run: >-
pytest tests
pytest tests --hypothesis-profile=ci
test-coverage:
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
from hypothesis import HealthCheck
from hypothesis import settings

settings.register_profile("exhaustive", max_examples=10_000)
settings.register_profile(
"exhaustive",
max_examples=10_000,
suppress_health_check=[HealthCheck.too_slow],
)
settings.register_profile(
"coverage",
max_examples=10,
suppress_health_check=[HealthCheck.too_slow],
)
settings.register_profile("ci", suppress_health_check=[HealthCheck.too_slow])
20 changes: 16 additions & 4 deletions tests/hypothesis/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
coords=st.one_of(
st.lists(
st.tuples(
st.floats(allow_subnormal=False),
st.floats(
allow_subnormal=False,
),
st.floats(allow_subnormal=False),
),
),
Expand All @@ -41,7 +43,7 @@ def test_fuzz_centroid(
if area == 0 or math.isnan(area):
assert math.isnan(center[0])
assert math.isnan(center[1])
else:
else: # pragma: no cover
assert isinstance(center[0], float)
assert isinstance(center[1], float)
assert len(center) == 2
Expand Down Expand Up @@ -196,8 +198,18 @@ def test_fuzz_compare_geo_interface(
@given(
points=st.lists(
st.tuples(
st.floats(allow_nan=False, allow_infinity=False, allow_subnormal=False),
st.floats(allow_nan=False, allow_infinity=False, allow_subnormal=False),
st.floats(
allow_nan=False,
allow_infinity=False,
allow_subnormal=False,
width=32,
),
st.floats(
allow_nan=False,
allow_infinity=False,
allow_subnormal=False,
width=32,
),
),
),
)
Expand Down

0 comments on commit 9c2063c

Please sign in to comment.