You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a new entry in the ongoing war between making Hypothesis impossible to misuse and the creativity of determined users. 😉
17:12 <doismellburning> Annotating `setUp` with `given` - is this a thing? Is it ScarySauce(TM)?
17:12 <@DRMacIver> It's not a thing
17:12 <@DRMacIver> I've no idea what would happen, but it would probably be hilariously confusing
17:13 <doismellburning> welp, it's in my codebase!
17:13 — @DRMacIver blinks
17:13 <doismellburning> cheers :)
17:15 <@DRMacIver> Maybe Hypothesis should error (with deprecation path) when @given is applied to methods that don't have "test" in the name
17:16 <doismellburning> that sounds like it might be useful
17:17 <@DRMacIver> Yeah
17:17 <@DRMacIver> Though I'm sure https://xkcd.com/1172/ applies
17:18 <doismellburning> lol
17:23 <@DRMacIver> Maybe I'll just check for setUp for now. I can't think of too many other cases where this would be a problem.
I'm not sure what quite the right level of checking is here. I feel like it's reasonable, especially with toy examples, to use @given on methods that aren't strictly tests, but I can't think of a good use for it being on setUp. Maybe we should just have a small blacklist of method names?
This should go through the usual deprecation -> error later path of course.
The text was updated successfully, but these errors were encountered:
I think the user error here isn't "@given on things without test in the name" - that would break use of non-English function names, or even just alternative test discovery conventions.
Instead, I'd look for "@given on methods on a subclass of unittest.TestCase, where the name is defined on unittest.TestCase".
It looks like we can do this in run_test_with_generator in given in core.py, by suitably cautious use of the __self__ attribute to get the class it's bound to, ismethod, and issubclass - it'll fit right in with the rest of core.py!
(update: nope, not that easy - the test isn't bound to any class at the point where it's decorated)
We have a new entry in the ongoing war between making Hypothesis impossible to misuse and the creativity of determined users. 😉
I'm not sure what quite the right level of checking is here. I feel like it's reasonable, especially with toy examples, to use
@givenon methods that aren't strictly tests, but I can't think of a good use for it being onsetUp. Maybe we should just have a small blacklist of method names?This should go through the usual deprecation -> error later path of course.
The text was updated successfully, but these errors were encountered: