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
If I pass an unspec'd mock to a function that is decorated by hypothesis.given then regardless of what the function does, hypothesis flags the function for not returning None.
Traceback (most recent call last):
File "test_foo.py", line 14, in <module>
test_foo_spec(Mock()) # Fails health check
File "test_foo.py", line 9, in test_foo_specdeftest_foo_spec(bar, inp):
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/core.py", line 477, in wrapped_test
runner.run()
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/internal/conjecture/engine.py", line 192, in runself._run()
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/internal/conjecture/engine.py", line 313, in _runself.new_buffer()
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/internal/conjecture/engine.py", line 76, in new_bufferself.test_function(self.last_data)
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/internal/conjecture/engine.py", line 82, in test_functionself._test_function(data)
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/core.py", line 453, in evaluate_test_data
) % (test.__name__, result), HealthCheck.return_value)
File "/Users/dan/.pyenv/versions/3.5.2/envs/test-hypo/lib/python3.5/site-packages/hypothesis/core.py", line 307, in fail_health_checkraise FailedHealthCheck(message)
hypothesis.errors.FailedHealthCheck: Tests run under @given should return None, but test_foo_spec returned <Mock name='mock.execute_example()' id='4365662752'> instead.
See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for more information about this. If you want to disable just this health check, add HealthCheck.return_value to the suppress_health_check settings for this test.
Yeah, you're running into a variant of #198 I think. mocks and given don't play very well together right now.
This is unfortunately quite hard to fix given the current semantics of how Hypothesis handles things at the moment and probably requires some major feature changes to work correctly. :-(
For the moment, recommended workaround is to use a spec for your mock.
If I pass an unspec'd mock to a function that is decorated by
hypothesis.giventhen regardless of what the function does, hypothesis flags the function for not returningNone.This snippet demonstrates the problem:
which results in:
I am running 3.5.2 with these packages installed:
The text was updated successfully, but these errors were encountered: