Skip to content

Commit

Permalink
Add target() example to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 2, 2022
1 parent b36c896 commit 43a1a8a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hypothesis-python/docs/details.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,19 @@ there is a natural metric like "floating-point error", "load factor" or

.. autofunction:: hypothesis.target

.. code-block:: python
from hypothesis import given, strategies as st, target
@given(st.floats(0, 1e100), st.floats(0, 1e100), st.floats(0, 1e100))
def test_associativity_with_target(a, b, c):
ab_c = (a + b) + c
a_bc = a + (b + c)
difference = abs(ab_c - a_bc)
target(difference) # Without this, the test almost always passes
assert difference < 2.0
We recommend that users also skim the papers introducing targeted PBT;
from `ISSTA 2017 <http://proper.softlab.ntua.gr/papers/issta2017.pdf>`__
and `ICST 2018 <http://proper.softlab.ntua.gr/papers/icst2018.pdf>`__.
Expand Down

0 comments on commit 43a1a8a

Please sign in to comment.