Skip to content
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

stateful _print_step doesn't display invariant #3185

Closed
touilleMan opened this issue Dec 8, 2021 · 0 comments · Fixed by #3186
Closed

stateful _print_step doesn't display invariant #3185

touilleMan opened this issue Dec 8, 2021 · 0 comments · Fixed by #3186
Labels
legibility make errors helpful and Hypothesis grokable

Comments

@touilleMan
Copy link
Member

touilleMan commented Dec 8, 2021

minimal example:

from hypothesis.stateful import *

class StateMachine(RuleBasedStateMachine):
    @invariant()
    def invariant1(self):
        assert False

    @rule()
    def rule1(self):
        assert True

run_state_machine_as_test(StateMachine)

Running this code gives:

Falsifying example:
state = StateMachine()
state.teardown()
Traceback (most recent call last):
  File "test42.py", line 33, in <module>
    run_state_machine_as_test(StateMachine)
  File "/home/emmanuel/projects/hypothesis-trio/venv/lib/python3.8/site-packages/hypothesis/stateful.py", line 75, in run_state_machine_as_test
    def run_state_machine_as_test(state_machine_factory, *, settings=None):
  File "/home/emmanuel/projects/hypothesis-trio/venv/lib/python3.8/site-packages/hypothesis/internal/reflection.py", line 655, in accept
    return func(*bound.args, **bound.kwargs)
  File "/home/emmanuel/projects/hypothesis-trio/venv/lib/python3.8/site-packages/hypothesis/stateful.py", line 200, in run_state_machine_as_test
    run_state_machine(state_machine_factory)
  File "/home/emmanuel/projects/hypothesis-trio/venv/lib/python3.8/site-packages/hypothesis/stateful.py", line 92, in run_state_machine
    @given(st.data())
  File "/home/emmanuel/projects/hypothesis-trio/venv/lib/python3.8/site-packages/hypothesis/core.py", line 1164, in wrapped_test
    raise the_error_hypothesis_found
  File "test42.py", line 27, in invariant1
    assert False
AssertionError

However the falsifying example displayed doesn't trigger the error.
The falsifying should be:

state = StateMachine()
state.invariant1()
state.teardown()
touilleMan added a commit to touilleMan/hypothesis that referenced this issue Dec 8, 2021
@Zac-HD Zac-HD added the legibility make errors helpful and Hypothesis grokable label Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants