From 7a489dbd116edd4ca5a6104b74748f3a4f712d15 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 22 Mar 2014 15:09:34 -0700 Subject: Fixed #809 -- switch back to always using UnsupportedAlgorithm --- tests/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 3e35970e..fbe448fe 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -14,11 +14,13 @@ from __future__ import absolute_import, division, print_function import collections +from contextlib import contextmanager import pytest import six +from cryptography.exceptions import UnsupportedAlgorithm import cryptography_vectors @@ -67,6 +69,13 @@ def check_backend_support(item): "backend") +@contextmanager +def raises_unsupported(cause): + with pytest.raises(UnsupportedAlgorithm) as exc_info: + yield + assert exc_info.value._cause == cause + + def load_vectors_from_file(filename, loader): with cryptography_vectors.open_vector_file(filename) as vector_file: return loader(vector_file) -- cgit v1.2.3 From 112963e296aadfdeaa4e2624c3b81b6b8c726a06 Mon Sep 17 00:00:00 2001 From: Alex Stapleton Date: Wed, 26 Mar 2014 17:39:29 +0000 Subject: Address most of my own comments --- tests/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index fbe448fe..f948642e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -70,10 +70,10 @@ def check_backend_support(item): @contextmanager -def raises_unsupported(cause): +def raises_unsupported_algorithm(cause): with pytest.raises(UnsupportedAlgorithm) as exc_info: - yield - assert exc_info.value._cause == cause + yield exc_info + assert exc_info.value._cause is cause def load_vectors_from_file(filename, loader): -- cgit v1.2.3 From 5e4c8c3666860fbe7320ea2227428f530cc8f176 Mon Sep 17 00:00:00 2001 From: Alex Stapleton Date: Thu, 27 Mar 2014 16:38:00 +0000 Subject: Fixes to @alex's comments --- tests/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index f948642e..3e5ea5f3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -70,10 +70,12 @@ def check_backend_support(item): @contextmanager -def raises_unsupported_algorithm(cause): +def raises_unsupported_algorithm(reason): with pytest.raises(UnsupportedAlgorithm) as exc_info: yield exc_info - assert exc_info.value._cause is cause + + if exc_info.value._reason is not reason: + pytest.fail("Did not get expected reason tag for UnsupportedAlgorithm") def load_vectors_from_file(filename, loader): -- cgit v1.2.3 From 85a791f0fa061ec644f5bfca41ee6038eeef38eb Mon Sep 17 00:00:00 2001 From: Alex Stapleton Date: Thu, 27 Mar 2014 16:55:41 +0000 Subject: Pain the bikeshed a different colour --- tests/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 3e5ea5f3..bdbf996f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -74,8 +74,7 @@ def raises_unsupported_algorithm(reason): with pytest.raises(UnsupportedAlgorithm) as exc_info: yield exc_info - if exc_info.value._reason is not reason: - pytest.fail("Did not get expected reason tag for UnsupportedAlgorithm") + assert exc_info.value._reason is reason def load_vectors_from_file(filename, loader): -- cgit v1.2.3