Repository navigation
gh-107862: Add stateful, timezones and ip_addresses to the Hypothesis stubs - #159770
Merged
Merged
Conversation
…thesis stubs The stubs in test.support._hypothesis_stubs only cover the strategies and decorators the existing property tests happen to use, so a test that wants hypothesis.stateful, or the timezones() and ip_addresses() strategies, fails to import when Hypothesis is not installed. This adds those names. The stateful API has no equivalent of @example, so there is nothing for the stub to replay: a state machine's TestCase is skipped and run_state_machine_as_test raises SkipTest. The decorators are accepted so that state machine classes can be defined at import time. Real Hypothesis only exposes hypothesis.stateful once the submodule has been imported, so hypothesis_helper now imports it, making the attribute available in both modes.
pganssle
force-pushed
the
hypothesis-stubs-stateful
branch
from
October 19, 2026 21:30
b88d3ad to
aeb677f
Compare
pganssle
marked this pull request as ready for review
October 19, 2026 21:45
gpshead
approved these changes
Oct 20, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The stubs in
test.support._hypothesis_stubsonly cover the strategies and decorators the existing property tests happen to use, so a test wantinghypothesis.stateful, or thetimezones()/ip_addresses()strategies, fails to import when Hypothesis is not installed.This adds those names. The stateful API has no equivalent of
@example, so there is nothing for the stub to replay: a state machine'sTestCaseis skipped andrun_state_machine_as_testraisesSkipTest. The decorators are accepted so state machine classes can be defined at import time.Real Hypothesis only exposes
hypothesis.statefulonce the submodule has been imported, sohypothesis_helpernow imports it, making the attribute available in both modes.The stubs had no tests of their own, so this also adds
test_hypothesis_stubs, which checks the replay and skip behavior directly and runs the API-shape checks against the real package when it is importable (i.e. in the "Hypothesis tests on Ubuntu" job).Groundwork for #107862; a stacked PR adding the first stateful/property users follows.