-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shrink pass for reordering examples
- Loading branch information
Showing
3 changed files
with
75 additions
and
11 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 |
---|---|---|
@@ -1,23 +1,21 @@ | ||
RELEASE_TYPE: patch | ||
|
||
This release improves the shrinker's ability to handle situations where there | ||
is an additive constraint between two values. | ||
This release improves the shrinker's ability to reorder examples. | ||
|
||
For example, consider the following test: | ||
|
||
|
||
.. code-block:: python | ||
import hypothesis.strategies as st | ||
from hypothesis import given | ||
@given(st.integers(), st.integers()) | ||
def test_does_not_exceed_100(m, n): | ||
assert m + n < 100 | ||
@given(st.text(), st.text()) | ||
def test_does_not_exceed_100(x, y): | ||
assert x != y | ||
Previously this could have failed with almost any pair ``(m, n)`` with | ||
``0 <= m <= n`` and ``m + n == 100``. Now it should almost always fail with | ||
``m=0, n=100``. | ||
Previously this could have failed with either of ``x="", y="0"`` or | ||
``x="0", y=""``. Now it should always fail with ``x="", y="0"``. | ||
|
||
This is a relatively niche specialisation, but can be useful in situations | ||
where e.g. a bug is triggered by an integer overflow. | ||
This will allow the shrinker to produce more consistent results, especially in | ||
cases where test cases contain some ordered collection whose actual order does | ||
not matter. |
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