Skip to content

Add chance to draw local constants in HypothesisProvider #4356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 16 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
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ jobs:
run: |
pip install --upgrade setuptools pip wheel
pip install -r requirements/coverage.txt
pip install hypothesis-python/[all]
pip install -r requirements/crosshair.txt
pip install hypothesis-python/
- name: Run tests
run: python -m pytest --numprocesses auto ${{ matrix.whichtests == 'nocover' && 'hypothesis-python/tests/nocover' || 'hypothesis-python/tests/ --ignore=hypothesis-python/tests/nocover/ --ignore=hypothesis-python/tests/quality/ --ignore=hypothesis-python/tests/ghostwriter/ --ignore=hypothesis-python/tests/patching/' }}

Expand Down
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

Hypothesis now looks for constant values in the source code of your program, and sometimes uses them while generating examples. This lets Hypothesis generate interesting inputs that are specific to your program.
10 changes: 10 additions & 0 deletions hypothesis-python/src/hypothesis/internal/conjecture/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,16 @@ def draw_float(
assert not math.isnan(min_value)
assert not math.isnan(max_value)

if smallest_nonzero_magnitude == 0.0: # pragma: no cover
raise FloatingPointError(
"Got allow_subnormal=True, but we can't represent subnormal floats "
"right now, in violation of the IEEE-754 floating-point "
"specification. This is usually because something was compiled with "
"-ffast-math or a similar option, which sets global processor state. "
"See https://simonbyrne.github.io/notes/fastmath/ for a more detailed "
"writeup - and good luck!"
)

if forced is not None:
assert allow_nan or not math.isnan(forced)
assert math.isnan(forced) or (
Expand Down
Loading