Created
June 28, 2017 15:03
-
-
Save shapr/fad8a27800c8927f03c65657d20aac2e to your computer and use it in GitHub Desktop.
simple hypothesis demo
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
from hypothesis import given | |
import hypothesis.strategies as st | |
import json | |
@given(st.one_of( st.integers(), st.text(), st.lists(st.text()))) | |
def test_decode_inverts_encode(s): | |
assert json.loads(json.dumps(s)) == s | |
@given(x=st.floats(), y=st.floats(), z=st.floats()) | |
def test_floats_commutative(x, y, z): | |
assert (x * y) * z == x * (y * z) | |
@given(x=st.floats()) | |
def test_floats_self_inverse(x): | |
assert x == -(-x) | |
if __name__ == '__main__': | |
test_decode_inverts_encode() | |
test_floats_commutative() | |
test_floats_self_inverse() |
Hi, I have a problem with hypothesis. every time I want to use it, I get an error:
AttributeError: 'function' object has no attribute '(My attribute)'
It happens with every attribute. What should I do to fix this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could
be expressed as
?