Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions hypothesis/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RELEASE_TYPE: patch

Document the "gotcha" that :func:`~hypothesis.strategies.nothing` is not
suitable for use as a placeholder strategy in "explicit
:class:`~hypothesis.example` only" setups. See :issue:`4774`.

Contributed by Marco Ricci.
10 changes: 10 additions & 0 deletions hypothesis/src/hypothesis/strategies/_internal/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def just(value: T) -> SearchStrategy[T]:
def none() -> SearchStrategy[None]:
"""Return a strategy which only generates None.

Useful as a placeholder strategy.

Examples from this strategy do not shrink (because there is only
one).
"""
Expand Down Expand Up @@ -125,6 +127,14 @@ def nothing() -> SearchStrategy["Never"]:
"""This strategy never successfully draws a value and will always reject on
an attempt to draw.

``nothing()`` is *not* suitable as a placeholder strategy in |@given|,
even when used together with |@example| and with only |Phase.explicit|
active, because it is too easy for a change in settings or settings profile
to cause the test to suddenly fail mysteriously. Prefer |st.none| as a
placeholder strategy for this use case. See `issue #4774
<https://github.com/HypothesisWorks/hypothesis/issues/4774>`__ for more
details.

Examples from this strategy do not shrink (because there are none).
"""
return NOTHING
Expand Down
Loading