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
Hi !
I ran into a problem with the falsifying examples produced by stateful testing with multiple results.
Consider the following state machine:
from hypothesis.stateful import Bundle, RuleBasedStateMachine from hypothesis.stateful import rule, multiple, initialize class DatabaseComparison(RuleBasedStateMachine): values = Bundle("values") @initialize(target=values) def produce(self): return multiple(1, 2, 3) @rule(v=values) def check(self, v): assert v == 1 TestDBComparison = DatabaseComparison.TestCase
It legitimately fails with the following info:
E AssertionError: assert 3 == 1 test_hypo.py:16: AssertionError ---------------------- Hypothesis -------------------- Falsifying example: state = DatabaseComparison() v1, v2, v3 = state.produce() state.check(v=v3) state.teardown()
Let's put the falsifying example into a dedicated test:
def test_reproduce(): state = DatabaseComparison() v1, v2, v3 = state.produce() state.check(v=v3) state.teardown()
The problem is that the test fails with the following error:
def test_reproduce(): state = DatabaseComparison() > v1, v2, v3 = state.produce() E TypeError: cannot unpack non-iterable MultipleResults object test_hypo.py:24: TypeError
This can be fixed with the following change:
def test_reproduce_fixed(): state = DatabaseComparison() v1, v2, v3 = state.produce().values state.check(v=v3) state.teardown()
Which does produce the right error:
E assert 3 == 1 test_hypo.py:16: AssertionError
The text was updated successfully, but these errors were encountered:
Document the work around for HypothesisWorks/hypothesis#2311
9ed2b50
Definitely a bug - fortunately it's easy to fix, just adding an __iter__ method to
__iter__
hypothesis/hypothesis-python/src/hypothesis/stateful.py
Lines 355 to 357 in 47f82a1
pasting your test case above into hypothesis-python/tests/cover/test_stateful.py.
hypothesis-python/tests/cover/test_stateful.py
Would you like to open a PR, so python-trio/hypothesis-trio#5 doesn't need a workaround?
Sorry, something went wrong.
@Zac-HD
Done: #2312 :)
No branches or pull requests
Hi !
I ran into a problem with the falsifying examples produced by stateful testing with multiple results.
Consider the following state machine:
It legitimately fails with the following info:
Let's put the falsifying example into a dedicated test:
The problem is that the test fails with the following error:
This can be fixed with the following change:
Which does produce the right error:
The text was updated successfully, but these errors were encountered: