-
Notifications
You must be signed in to change notification settings - Fork 583
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
assume plus example interacts badly with pytest.mark.parametrize #2125
Comments
Hmm, this will probably be a pain to track down and fix - We'll also need to decide what should happen when you pass different arguments to Either way, thanks so much for bringing this to our attention! (I should also mention that I'm a huge fan of how you're applying property-based testing in science! 😁 I've been pushing it at conferences for a while but I'm no longer a regular enough contributor to have much luck with PRs...) |
Ah, that makes sense mechanically. There's also some fragility in terms of order of fixtures, parametrize arguments, and hypothesis-supplied arguments.
I'm not quite sure what you mean here? I really like being able to combine
Thanks! I actually gave a talk at a python in astronomy conference about property-based testing several years before I even heard of hypothesis, though it was a case that I don't see how hypothesis covers (yet?): I was talking about checking frequentist statistical tests - if the K-S test tells you that there's only a one in a thousand chance that your uniformly-distributed values would be this clumpy, there's a decent chance you have a bug somewhere. If you repeat the test with a different seed and it fails again? Probably a bug. I put a few such tests into scipy years and years ago but I bet people have replaced them because they took a long time. |
Yes, absolutely! Mixing
Niiice. Hypothesis by design doesn't cover this kind of thing though; the net effect of a pile of heuristics and an example-generator that often mutates existing examples is that you really can't rely on getting any particular distribution out, or even find a simple way to characterise the one you get beyond "it's likely to trigger exceptions" 😉 |
Oh, that's not what I'm worried about. I'm picturing using hypothesis to generate, say, distribution parameters or array sizes or whatever, and then the endpoint test would be one of these statistical things - I generate as many points as hypothesis asked for according to the distribution parameters then run them through one of these tests. The problem arises with the fact that these tests are inherently flaky by hypothesis standards (and also slow). I'm still thinking about whether it's feasible to combine the two techniques. |
Right, you could use Hypothesis for that but personally I wouldn't, partly because it would be flaky and partly because I'm not sure shrinking would help much. If you're also generating a seed for your PRNG though, I can see that Hypothesis' replay capabilities could make it worthwhile 😄 |
I can see why I see hypothesis.errors.UnsatisfiedAssumption when I supply an example that fails to satisfy the assumption, though it is inconvenient (I prefer to leave old failures lying around in @example in case I want to remove the assumption later). But it seems like @example is not respecting the parametrized argument it contains? That is, the hypothesis-generated parts are being combined with both parametrize values, and when the example doesn't pass the assumption, I see UnsatisfiedAssumption - even though it is for a combination of values I did not specify.
Sorry, that's not a very clear explanation. But perhaps this contrived example will help:
yields
and
The text was updated successfully, but these errors were encountered: