Skip to content

Instantly share code, notes, and snippets.

@JakeTheCorn
Created July 16, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeTheCorn/8156d814cb3ab1d01e358e7a3363eea0 to your computer and use it in GitHub Desktop.
Save JakeTheCorn/8156d814cb3ab1d01e358e7a3363eea0 to your computer and use it in GitHub Desktop.
prop based testing sample (not a great one)
import unittest
from hypothesis import given, example, settings, reproduce_failure
import hypothesis.strategies as st
def is_even(v):
return v % 2 == 0
class Test(unittest.TestCase):
@given(st.integers())
@settings(max_examples=100, print_blob=True)
def test_is_even(self, x):
res = is_even(x)
print(x)
assert res == (x % 2 == 0)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment