Created
July 16, 2020 18:32
-
-
Save JakeTheCorn/8156d814cb3ab1d01e358e7a3363eea0 to your computer and use it in GitHub Desktop.
prop based testing sample (not a great one)
This file contains 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 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