Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement