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
Print seed on test failure to aid reproduction #860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - this is the kind of important but unglamorous work that distinguishes really cool projects from really useful projects. Thanks to Smarkets for funding it!
RELEASE.rst
Outdated
| * pytest users can specify a seed to use for ``@given`` based tests by passing | ||
| the ``--hypothesis-seed`` command line argument. | ||
| * When a test fails, either with a health check failure or a falsifying example, | ||
| Hypothesis will print out a seed that lead to that failure if the test is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"lead" -> "led" or "leads"; or just reread the whole sentence and decide on a tense.
|
Not much more to say really - it's a solid and useful change, but probably not something to write a blog post about |
I am in fact scheduled to write a blog post about it. More specifically, Smarkets are paying for a bunch of feature dev, mostly around making Hypothesis performance problems more legible (this fits into that because it lets you reproduce the exact scenario that lead to a failed health check, which I totally forgot to mention as a use case in the preamble above!). Once I've finished all of them I'm going to write a blog post about the whole set of work and the motivations leading up to it. |
64cf907
to
2b0c94c
Compare
7e176d8
to
c13135b
Compare
Users often find themselves in one or more of the following scenarios:
@example.This can make it annoying to impossible to reproduce failures from CI locally.
This PR aims to mitigate that: When a test fails, if the random seed required to reproduce that test was not already set deterministically (with
@seedorderandomize=Trueor with the command line argument I'll mention in a moment), Hypothesis will print out the seed it used along with instructions on how to use it to reproduce the example.In order to make that information more readily useful and allow reproducing examples without editing the source code, this also adds a command line flag for pytest users to pass the seed explicitly.