-
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
Hypothesis doesn't recognize unittest.SkipTest exception #514
Comments
|
Thanks for the report! I had a quick go at trying to write an example – is this sort of like what you were doing? import unittest
from hypothesis import given
from hypothesis.strategies import integers
class DemoTest(unittest.TestCase):
@given(integers())
def test_to_be_skipped(self, x):
if x == 0:
raise unittest.SkipTest()
else:
assert x == 0
unittest.main()$ python issue514.py
Falsifying example: test_to_be_skipped(self=<__main__.DemoTest testMethod=test_to_be_skipped>, x=0)
s
----------------------------------------------------------------------
Ran 1 test in 0.021s
OK (skipped=1)Sounds like we should just recognise |
|
Yes, that's the essence of the issue. Agreed with the proposed course of
action. I feel like I should have submitted a PR to go with this bug
report, but I don't know anything about Hypothesis' internals.
…On Thu, Apr 13, 2017 at 3:29 PM, Alex Chan ***@***.***> wrote:
Thanks for the report! I had a quick go at trying to write an example – is
this sort of like what you were doing?
import unittest
from hypothesis import givenfrom hypothesis.strategies import integers
class DemoTest(unittest.TestCase):
@given(integers())
def test_to_be_skipped(self, x):
if x == 0:
raise unittest.SkipTest()
else:
assert x == 0
unittest.main()
$ python issue514.pyFalsifying example: test_to_be_skipped(self=<__main__.DemoTest testMethod=test_to_be_skipped>, x=0)s----------------------------------------------------------------------Ran 1 test in 0.021s
OK (skipped=1)
Sounds like we should just recognise unittest.SkipTest as a special
exception – I get the same result whether I raise the exception directly or
call self.skipTest(reason). Not sure how hard that is off the top of my
head.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#514 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHdeTr5MlcE7IqXHHhCasQKBMK_wfBRDks5rviMxgaJpZM4M8sBy>
.
|
|
So at a very quick glance, I think we need to make a change somewhere around line 464 of core.py so that if we catch a I’m not sure what mechanisms we have for marking a test as skipped (as opposed to just silently dropping the error) – I’ll dig in a little further when I have more time. |
I think just immediately reraising the error should have the desired effect shouldn't it? |
Oh yeah. PR incoming. :) |
|
@coriolinus This took longer than I was expecting to finish, but the fix is now released as Hypothesis 3.13. Thanks for your bug report! |
|
I'm very glad to hear it! Thanks for fixing this.
…On Thu, Jul 20, 2017 at 5:27 PM, Alex Chan ***@***.***> wrote:
@coriolinus <https://github.com/coriolinus> This took longer than I was
expecting to finish, but the fix is now released as Hypothesis 3.13.
Thanks for your report!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#514 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHdeTt8CtFeHwfw2clHGoqP8cqnjpVQtks5sP3H4gaJpZM4M8sBy>
.
|
Narrative example of failure
I haven't had time to construct a minimal example, so I'll give a full example of failure. I've recently updated a test in my Django project which conditionally skips a test in cases which no longer make sense.
The test in question is defined in an abstract base class of a couple other test classes which specialize it further. One branch of one test no longer makes sense in the context of one of the specialization classes. I can't solve this with
assume()or@unittest.skipIf()because neither has enough contextual data. Instead, Iraise unittest.SkipTest()at runtime if the test should be skipped.The issue is that Hypothesis doesn't know about
unittest.SkipTest, so produces failure output, as seen below:Expected behavior
Hypothesis does not produce failure output if a test raises
unittest.SkipTest.Observed behavior
Hypothesis produces failure output if a test raises
unittest.SkipTest.The text was updated successfully, but these errors were encountered: