From 783479c6189d788ac2f721b5b017073736c578cb Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 26 Dec 2013 21:08:45 -0600 Subject: refactor all tests to use mark instead of generator skips --- tests/hazmat/primitives/test_hmac.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tests/hazmat/primitives/test_hmac.py') diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index 6d8cc27b..c216dd4d 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -13,6 +13,8 @@ from __future__ import absolute_import, division, print_function +import binascii + import pretend import pytest @@ -23,8 +25,6 @@ from cryptography import utils from cryptography.exceptions import AlreadyFinalized, UnsupportedAlgorithm from cryptography.hazmat.primitives import hashes, hmac, interfaces -from .utils import generate_base_hmac_test - @utils.register_interface(interfaces.HashAlgorithm) class UnsupportedDummyHash(object): @@ -33,11 +33,16 @@ class UnsupportedDummyHash(object): @pytest.mark.hmac class TestHMAC(object): - test_copy = generate_base_hmac_test( - hashes.MD5(), + @pytest.mark.supported( only_if=lambda backend: backend.hmac_supported(hashes.MD5), skip_message="Does not support MD5", ) + def test_hmac_copy(self, backend): + key = b"ab" + h = hmac.HMAC(binascii.unhexlify(key), hashes.MD5(), backend=backend) + h_copy = h.copy() + assert h != h_copy + assert h._ctx != h_copy._ctx def test_hmac_reject_unicode(self, backend): h = hmac.HMAC(b"mykey", hashes.SHA1(), backend=backend) -- cgit v1.2.3 From b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 27 Dec 2013 16:33:14 -0600 Subject: re-add some removed generators to simplify patch --- tests/hazmat/primitives/test_hmac.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/hazmat/primitives/test_hmac.py') diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index c216dd4d..924e2167 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -13,8 +13,6 @@ from __future__ import absolute_import, division, print_function -import binascii - import pretend import pytest @@ -25,25 +23,27 @@ from cryptography import utils from cryptography.exceptions import AlreadyFinalized, UnsupportedAlgorithm from cryptography.hazmat.primitives import hashes, hmac, interfaces +from .utils import generate_base_hmac_test + @utils.register_interface(interfaces.HashAlgorithm) class UnsupportedDummyHash(object): name = "unsupported-dummy-hash" +@pytest.mark.supported( + only_if=lambda backend: backend.hmac_supported(hashes.MD5), + skip_message="Does not support MD5", +) @pytest.mark.hmac -class TestHMAC(object): - @pytest.mark.supported( - only_if=lambda backend: backend.hmac_supported(hashes.MD5), - skip_message="Does not support MD5", +class TestHMACCopy(object): + test_copy = generate_base_hmac_test( + hashes.MD5(), ) - def test_hmac_copy(self, backend): - key = b"ab" - h = hmac.HMAC(binascii.unhexlify(key), hashes.MD5(), backend=backend) - h_copy = h.copy() - assert h != h_copy - assert h._ctx != h_copy._ctx + +@pytest.mark.hmac +class TestHMAC(object): def test_hmac_reject_unicode(self, backend): h = hmac.HMAC(b"mykey", hashes.SHA1(), backend=backend) with pytest.raises(TypeError): -- cgit v1.2.3