Created
November 27, 2019 17:23
-
-
Save DRMacIver/fdb24bdd7518eb50f30c665aa3e2c5fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from hypothesis import given, strategies as st, settings, Verbosity | |
| if __name__ == '__main__': | |
| target = sys.argv[1] | |
| with open(target) as i: | |
| source = i.read() | |
| exec_globals = {} | |
| exec(source, exec_globals) | |
| sut_class = exec_globals["sut"] | |
| @settings(verbosity=Verbosity.debug, deadline=None) | |
| @given(st.data()) | |
| def test(data): | |
| n_steps = data.draw(st.integers(1, 100)) | |
| sut = sut_class() | |
| actions = {t[0]: t for t in sut.actions()} | |
| action_names = sorted(actions, key=lambda s: (len(s), s)) | |
| for _ in range(n_steps): | |
| name, guard, act = actions[data.draw(st.sampled_from(action_names).filter(lambda t: actions[t][1]()))] | |
| act() | |
| test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment