-
Notifications
You must be signed in to change notification settings - Fork 586
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
settings.derandomize is ineffective for some strategies #966
Comments
|
I have an example code with @given in which derandomize does not work. I have tried to modify it into a minimal verifiable example (that is why it might seem slightly odd). If I change the code slightly, the bug sometimes disappears, which leads me to think that it only manifests with certain random seeds. What is also interesting is that the code is not completely random, it switches between two different outcomes (tested on thousands of runs). The outcomes are also part of the zip file (derandomize_bug_result1.txt and ...result2.txt). |
|
I have tried running git bisect with the following results:
|
|
I encountered what I believe is the same issue and debugged it, and it boiled down to hypothesis leaning on the hash of strings being predictable. When hash randomization is active, derandomize results in a unique seed. This is always the case in python3, and in python2 can be activated with the interpreter I did a hack to change derandomize to use hashlib.sha1, and it started working. I can (re-derive and) contribute this patch, if there's interest. |
That would be fantastic - especially if you can also write up a brief explanation of how the bug arose and why sha1 avoids it 😄 |
Hmm. Are you sure? I mean it makes sense that that's the problem somewhere, but I don't think it's in the derandomize code! derandomize uses function_digest, which is already based on hashlib. I'm sure you're right that the problem is hash randomization, I just think that it's probably got to be us depending on dict iteration order or something somewhere. |
|
@DRMacIver |
|
@nikola-benes - can you test again to confirm that #1217 fixes the issue? Note that this assumes you are running Python2 with hash randomisation enabled - if not I'll need to go trace everything again 😞 @bukzor - |
Oh! Right. That makes sense. Sigh. Thanks. |
|
...and we don't actually want to modify |
|
I wrote the code for that. (from memory) |
|
For #1217 I just used |
This was discovered while working on #962, and "fixed" by calling
random.seed(0)before each doctest block. Things that seem to be affected:.mapand.filterst.recursiveandst.deferredfindWhile
integers().example()is unaffected, along withtuple(...),builds(...), etc. I therefore suspect that something in the composition of strategies is making the derandomize machinery fail.Note that this has only been observed in output from
s.example()- it is unknown whether it also affects tests defined with@given.The text was updated successfully, but these errors were encountered: