diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-02 10:42:34 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-10-02 10:42:34 -0500 |
commit | 1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff (patch) | |
tree | fc3142c867fbf514345e31ae4b3fd7551be5c947 | |
parent | 9ab8e7a540eebc802da0eaa73fbefe0a2af4ac9a (diff) | |
parent | e98df9c97b764420ab5c89b64ed4d7c164e28e50 (diff) | |
download | cryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.tar.gz cryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.tar.bz2 cryptography-1dea513d7a0fb6c1a3c1df2924db1bd1135f78ff.zip |
Merge pull request #1773 from Ayrx/hypothesis
Property based testing with Hypothesis
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | dev-requirements.txt | 2 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/hypothesis/__init__.py | 5 | ||||
-rw-r--r-- | tests/hypothesis/test_fernet.py | 11 | ||||
-rw-r--r-- | tox.ini | 4 |
6 files changed, 24 insertions, 1 deletions
@@ -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 @@ -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 @@ -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 |