aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--dev-requirements.txt2
-rw-r--r--setup.py2
-rw-r--r--tests/hypothesis/__init__.py5
-rw-r--r--tests/hypothesis/test_fernet.py11
-rw-r--r--tox.ini4
6 files changed, 24 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 8a870e05..60f90063 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ htmlcov/
*.egg
.eggs/
*.py[co]
+.hypothesis/
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 440d3b0f..55aebd4f 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -12,5 +12,7 @@ sphinx_rtd_theme
sphinxcontrib-spelling
tox
twine
+hypothesis
+hypothesis-pytest
-e .
-e vectors
diff --git a/setup.py b/setup.py
index b36f3de6..167b62e0 100644
--- a/setup.py
+++ b/setup.py
@@ -60,6 +60,8 @@ test_requirements = [
"pytest<2.8",
"pretend",
"iso8601",
+ "hypothesis",
+ "hypothesis-pytest",
]
# If there's no vectors locally that probably means we are in a tarball and
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
diff --git a/tox.ini b/tox.ini
index a890e38a..8b4343d0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,6 +8,8 @@ deps =
iso8601
pretend
pytest<2.8
+ hypothesis>=1.11.4
+ hypothesis-pytest
./vectors
passenv = ARCHFLAGS LDFLAGS CFLAGS INCLUDE LIB LD_LIBRARY_PATH USERNAME
commands =
@@ -85,7 +87,7 @@ commands =
py.test --capture=no --strict --random {posargs}
[flake8]
-exclude = .tox,*.egg,.git,_build
+exclude = .tox,*.egg,.git,_build,.hypothesis
select = E,W,F,N,I
application-import-names = cryptography,cryptography_vectors,tests