Skip to content

Instantly share code, notes, and snippets.

@Tinche
Created October 10, 2016 20:13
Show Gist options
  • Select an option

  • Save Tinche/e1339718ff9d5b56e1c50773f3a7a8a2 to your computer and use it in GitHub Desktop.

Select an option

Save Tinche/e1339718ff9d5b56e1c50773f3a7a8a2 to your computer and use it in GitHub Desktop.
from hypothesis.stateful import RuleBasedStateMachine, run_state_machine_as_test, rule, precondition
def test_t():
class StatefulTest(RuleBasedStateMachine):
def __init__(self):
print("init")
super().__init__()
self.a = False
self.b = False
self.c = False
@rule()
def open_a(self):
self.a = True
@rule()
@precondition(lambda self: self.a)
def open_b(self):
self.b = True
@rule()
@precondition(lambda self: self.b)
def open_c(self):
self.c = True
@rule()
@precondition(lambda self: self.c)
def final(self):
pass
run_state_machine_as_test(StatefulTest)
test_t.is_hypothesis_test = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment