aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-02 10:42:34 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-02 10:42:34 -0500
commit1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff (patch)
treefc3142c867fbf514345e31ae4b3fd7551be5c947 /tests
parent9ab8e7a540eebc802da0eaa73fbefe0a2af4ac9a (diff)
parente98df9c97b764420ab5c89b64ed4d7c164e28e50 (diff)
downloadcryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.tar.gz
cryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.tar.bz2
cryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.zip
Merge pull request #1773 from Ayrx/hypothesis
Property based testing with Hypothesis
Diffstat (limited to 'tests')
-rw-r--r--tests/hypothesis/__init__.py5
-rw-r--r--tests/hypothesis/test_fernet.py11
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/hypothesis/__init__.py b/tests/hypothesis/__init__.py
new file mode 100644
index 00000000..4b540884
--- /dev/null
+++ b/tests/hypothesis/__init__.py
@@ -0,0 +1,5 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from __future__ import absolute_import, division, print_function
diff --git a/tests/hypothesis/test_fernet.py b/tests/hypothesis/test_fernet.py
new file mode 100644
index 00000000..fd243803
--- /dev/null
+++ b/tests/hypothesis/test_fernet.py
@@ -0,0 +1,11 @@
+from hypothesis import given
+from hypothesis.strategies import binary
+
+from cryptography.fernet import Fernet
+
+
+@given(binary())
+def test_fernet(data):
+ f = Fernet(Fernet.generate_key())
+ ct = f.encrypt(data)
+ assert f.decrypt(ct) == data