Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. from hypothesis import given
  2. import hypothesis.strategies as st
  3.  
  4. import json
  5.  
  6. @given(st.one_of( st.integers(), st.text(), st.lists(st.text())))
  7. def test_decode_inverts_encode(s):
  8. assert json.loads(json.dumps(s)) == s
  9.  
  10. @given(x=st.floats(), y=st.floats(), z=st.floats())
  11. def test_floats_commutative(x, y, z):
  12. assert (x * y) * z == x * (y * z)
  13.  
  14.  
  15. @given(x=st.floats())
  16. def test_floats_self_inverse(x):
  17. assert x == -(-x)
  18.  
  19. if __name__ == '__main__':
  20. test_decode_inverts_encode()
  21. test_floats_commutative()
  22. test_floats_self_inverse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement