From cc2a828883d03800b3d7a145571796f01f3ed7d9 Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Sun, 22 Mar 2015 12:06:45 +0800 Subject: Add hypothesis test for Fernet. --- tests/test_with_hypothesis.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_with_hypothesis.py (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py new file mode 100644 index 00000000..261a21d6 --- /dev/null +++ b/tests/test_with_hypothesis.py @@ -0,0 +1,12 @@ +import pytest + +from cryptography.fernet import Fernet + +hypothesis = pytest.importorskip("hypothesis") + + +@hypothesis.given(bytes) +def test_fernet(data): + f = Fernet(Fernet.generate_key()) + ct = f.encrypt(data) + assert f.decrypt(ct) == data -- cgit v1.2.3 From 42ea0d1795797c7f52ba714147e2bbc29dad9deb Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Sun, 27 Sep 2015 20:26:09 +0800 Subject: Pin version of hypothesis above 1.11.4. --- tests/test_with_hypothesis.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py index 261a21d6..1e39b6b1 100644 --- a/tests/test_with_hypothesis.py +++ b/tests/test_with_hypothesis.py @@ -1,11 +1,14 @@ +from hypothesis import binary + import pytest from cryptography.fernet import Fernet + hypothesis = pytest.importorskip("hypothesis") -@hypothesis.given(bytes) +@hypothesis.given(binary()) def test_fernet(data): f = Fernet(Fernet.generate_key()) ct = f.encrypt(data) -- cgit v1.2.3 From 3d7f8d1d6cf268f5c0c482c8d1cce7ec773a7030 Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Sun, 27 Sep 2015 21:00:58 +0800 Subject: Use correct import. --- tests/test_with_hypothesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py index 1e39b6b1..31dfa04c 100644 --- a/tests/test_with_hypothesis.py +++ b/tests/test_with_hypothesis.py @@ -1,4 +1,4 @@ -from hypothesis import binary +from hypothesis.strategies import binary import pytest -- cgit v1.2.3 From 36a787ff216dff16e49c3cbc8895515588697337 Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Wed, 30 Sep 2015 19:13:14 +0800 Subject: Address comments. --- tests/test_with_hypothesis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py index 31dfa04c..5a181216 100644 --- a/tests/test_with_hypothesis.py +++ b/tests/test_with_hypothesis.py @@ -1,3 +1,4 @@ +from hypothesis import given from hypothesis.strategies import binary import pytest @@ -8,7 +9,7 @@ from cryptography.fernet import Fernet hypothesis = pytest.importorskip("hypothesis") -@hypothesis.given(binary()) +@given(binary()) def test_fernet(data): f = Fernet(Fernet.generate_key()) ct = f.encrypt(data) -- cgit v1.2.3 From dcf643f20bee524e748a85221e45c8152afa7478 Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Wed, 30 Sep 2015 19:13:56 +0800 Subject: Remove unneeded line. --- tests/test_with_hypothesis.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py index 5a181216..738549f6 100644 --- a/tests/test_with_hypothesis.py +++ b/tests/test_with_hypothesis.py @@ -6,9 +6,6 @@ import pytest from cryptography.fernet import Fernet -hypothesis = pytest.importorskip("hypothesis") - - @given(binary()) def test_fernet(data): f = Fernet(Fernet.generate_key()) -- cgit v1.2.3 From ea3a2325fde4be04ba65a2c07e4847235e71e89d Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Wed, 30 Sep 2015 19:23:58 +0800 Subject: Remove unused import. --- tests/test_with_hypothesis.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py index 738549f6..fd243803 100644 --- a/tests/test_with_hypothesis.py +++ b/tests/test_with_hypothesis.py @@ -1,8 +1,6 @@ from hypothesis import given from hypothesis.strategies import binary -import pytest - from cryptography.fernet import Fernet -- cgit v1.2.3 From e98df9c97b764420ab5c89b64ed4d7c164e28e50 Mon Sep 17 00:00:00 2001 From: Terry Chia Date: Fri, 2 Oct 2015 22:48:49 +0800 Subject: Move hypothesis tests to the subfolder. --- tests/hypothesis/__init__.py | 5 +++++ tests/hypothesis/test_fernet.py | 11 +++++++++++ tests/test_with_hypothesis.py | 11 ----------- 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 tests/hypothesis/__init__.py create mode 100644 tests/hypothesis/test_fernet.py delete mode 100644 tests/test_with_hypothesis.py (limited to 'tests') 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/tests/test_with_hypothesis.py b/tests/test_with_hypothesis.py deleted file mode 100644 index fd243803..00000000 --- a/tests/test_with_hypothesis.py +++ /dev/null @@ -1,11 +0,0 @@ -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 -- cgit v1.2.3