aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2013-11-25 09:14:02 -0800
committerDavid Reid <dreid@dreid.org>2013-11-25 09:14:02 -0800
commit9a1b0c75518e6eb2b4c0cb8fd35d94dad124ccd6 (patch)
treefcf18c36427b50aa213e171ae11be69541ea3658 /tests/hazmat
parentcf3ad610b2530af2a56f99197ae85718fa90f439 (diff)
downloadcryptography-9a1b0c75518e6eb2b4c0cb8fd35d94dad124ccd6.tar.gz
cryptography-9a1b0c75518e6eb2b4c0cb8fd35d94dad124ccd6.tar.bz2
cryptography-9a1b0c75518e6eb2b4c0cb8fd35d94dad124ccd6.zip
Use keyword argument forms everywhere.
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/primitives/test_hashes.py8
-rw-r--r--tests/hazmat/primitives/test_hmac.py9
-rw-r--r--tests/hazmat/primitives/utils.py14
3 files changed, 16 insertions, 15 deletions
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index 321082f6..c8719b0a 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -27,7 +27,7 @@ from .utils import generate_base_hash_test
class TestHashContext(object):
def test_hash_reject_unicode(self, backend):
- m = hashes.Hash(hashes.SHA1(), backend)
+ m = hashes.Hash(hashes.SHA1(), backend=backend)
with pytest.raises(TypeError):
m.update(six.u("\u00FC"))
@@ -35,16 +35,16 @@ class TestHashContext(object):
pretend_backend = pretend.stub()
copied_ctx = pretend.stub()
pretend_ctx = pretend.stub(copy=lambda: copied_ctx)
- h = hashes.Hash(hashes.SHA1(), pretend_backend, ctx=pretend_ctx)
+ h = hashes.Hash(hashes.SHA1(), backend=pretend_backend, ctx=pretend_ctx)
assert h._backend is pretend_backend
assert h.copy()._backend is h._backend
def test_hash_algorithm_instance(self, backend):
with pytest.raises(TypeError):
- hashes.Hash(hashes.SHA1, backend)
+ hashes.Hash(hashes.SHA1, backend=backend)
def test_raises_after_finalize(self, backend):
- h = hashes.Hash(hashes.SHA1(), backend)
+ h = hashes.Hash(hashes.SHA1(), backend=backend)
h.finalize()
with pytest.raises(AlreadyFinalized):
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 622f186a..992bcb1a 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -33,7 +33,7 @@ class TestHMAC(object):
)
def test_hmac_reject_unicode(self, backend):
- h = hmac.HMAC(b"mykey", hashes.SHA1(), backend)
+ h = hmac.HMAC(b"mykey", hashes.SHA1(), backend=backend)
with pytest.raises(TypeError):
h.update(six.u("\u00FC"))
@@ -42,16 +42,17 @@ class TestHMAC(object):
pretend_backend = pretend.stub(hmacs=pretend_hmac)
copied_ctx = pretend.stub()
pretend_ctx = pretend.stub(copy=lambda: copied_ctx)
- h = hmac.HMAC(b"key", hashes.SHA1(), pretend_backend, ctx=pretend_ctx)
+ h = hmac.HMAC(b"key", hashes.SHA1(), backend=pretend_backend,
+ ctx=pretend_ctx)
assert h._backend is pretend_backend
assert h.copy()._backend is pretend_backend
def test_hmac_algorithm_instance(self, backend):
with pytest.raises(TypeError):
- hmac.HMAC(b"key", hashes.SHA1, backend)
+ hmac.HMAC(b"key", hashes.SHA1, backend=backend)
def test_raises_after_finalize(self, backend):
- h = hmac.HMAC(b"key", hashes.SHA1(), backend)
+ h = hmac.HMAC(b"key", hashes.SHA1(), backend=backend)
h.finalize()
with pytest.raises(AlreadyFinalized):
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index c476a75c..6c67ddb3 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -42,7 +42,7 @@ def encrypt_test(backend, cipher_factory, mode_factory, params, only_if,
cipher = Cipher(
cipher_factory(**params),
mode_factory(**params),
- backend
+ backend=backend
)
encryptor = cipher.encryptor()
actual_ciphertext = encryptor.update(binascii.unhexlify(plaintext))
@@ -82,7 +82,7 @@ def stream_encryption_test(backend, cipher_factory, params, only_if,
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
offset = params.pop("offset")
- cipher = Cipher(cipher_factory(**params), None, backend)
+ cipher = Cipher(cipher_factory(**params), None, backend=backend)
encryptor = cipher.encryptor()
# throw away offset bytes
encryptor.update(b"\x00" * int(offset))
@@ -121,7 +121,7 @@ def hash_test(backend, algorithm, params, only_if, skip_message):
pytest.skip(skip_message)
msg = params[0]
md = params[1]
- m = hashes.Hash(algorithm, backend)
+ m = hashes.Hash(algorithm, backend=backend)
m.update(binascii.unhexlify(msg))
expected_md = md.replace(" ", "").lower().encode("ascii")
assert m.finalize() == binascii.unhexlify(expected_md)
@@ -148,7 +148,7 @@ def base_hash_test(backend, algorithm, digest_size, block_size, only_if,
if only_if is not None and not only_if(backend):
pytest.skip(skip_message)
- m = hashes.Hash(algorithm, backend)
+ m = hashes.Hash(algorithm, backend=backend)
assert m.algorithm.digest_size == digest_size
assert m.algorithm.block_size == block_size
m_copy = m.copy()
@@ -180,7 +180,7 @@ def generate_long_string_hash_test(hash_factory, md, only_if=None,
def long_string_hash_test(backend, algorithm, md, only_if, skip_message):
if only_if is not None and not only_if(backend):
pytest.skip(skip_message)
- m = hashes.Hash(algorithm, backend)
+ m = hashes.Hash(algorithm, backend=backend)
m.update(b"a" * 1000000)
assert m.finalize() == binascii.unhexlify(md.lower().encode("ascii"))
@@ -211,7 +211,7 @@ def hmac_test(backend, algorithm, params, only_if, skip_message):
msg = params[0]
md = params[1]
key = params[2]
- h = hmac.HMAC(binascii.unhexlify(key), algorithm, backend)
+ h = hmac.HMAC(binascii.unhexlify(key), algorithm, backend=backend)
h.update(binascii.unhexlify(msg))
assert h.finalize() == binascii.unhexlify(md.encode("ascii"))
@@ -233,7 +233,7 @@ def base_hmac_test(backend, algorithm, only_if, skip_message):
if only_if is not None and not only_if(backend):
pytest.skip(skip_message)
key = b"ab"
- h = hmac.HMAC(binascii.unhexlify(key), algorithm, backend)
+ h = hmac.HMAC(binascii.unhexlify(key), algorithm, backend=backend)
h_copy = h.copy()
assert h != h_copy
assert h._ctx != h_copy._ctx