aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-19 17:11:48 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-19 17:11:48 -0700
commita4444554aca86bb27ecfbedff81759b904bcd7b9 (patch)
tree81d1fe93e2b958c11213a96bbfad423d641b02a4
parent107b74ed7f973f104ede1c30ac6d3e020792afe0 (diff)
parent2acd77aa20b3a6e8eacf33d6e0cc7df4b438799d (diff)
downloadcryptography-a4444554aca86bb27ecfbedff81759b904bcd7b9.tar.gz
cryptography-a4444554aca86bb27ecfbedff81759b904bcd7b9.tar.bz2
cryptography-a4444554aca86bb27ecfbedff81759b904bcd7b9.zip
Merge pull request #143 from dstufft/require-100-coverage
Fail tests if our coverage is less than 100%
-rw-r--r--tests/primitives/utils.py12
-rw-r--r--tests/test_utils.py14
-rw-r--r--tests/utils.py2
-rw-r--r--tox.ini2
4 files changed, 23 insertions, 7 deletions
diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py
index 8b32700b..a3759b03 100644
--- a/tests/primitives/utils.py
+++ b/tests/primitives/utils.py
@@ -43,7 +43,7 @@ def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
def generate_hash_test(param_loader, path, file_names, hash_cls,
- only_if=lambda api: True, skip_message=None):
+ only_if=None, skip_message=None):
def test_hash(self):
for api in _ALL_APIS:
for file_name in file_names:
@@ -60,7 +60,7 @@ def generate_hash_test(param_loader, path, file_names, hash_cls,
def hash_test(api, hash_cls, params, only_if, skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
msg = params[0]
md = params[1]
@@ -70,7 +70,7 @@ def hash_test(api, hash_cls, params, only_if, skip_message):
def generate_base_hash_test(hash_cls, digest_size, block_size,
- only_if=lambda api: True, skip_message=None):
+ only_if=None, skip_message=None):
def test_base_hash(self):
for api in _ALL_APIS:
yield (
@@ -87,7 +87,7 @@ def generate_base_hash_test(hash_cls, digest_size, block_size,
def base_hash_test(api, hash_cls, digest_size, block_size, only_if,
skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
m = hash_cls(api=api)
assert m.digest_size == digest_size
@@ -97,7 +97,7 @@ def base_hash_test(api, hash_cls, digest_size, block_size, only_if,
assert m._ctx != m_copy._ctx
-def generate_long_string_hash_test(hash_factory, md, only_if=lambda api: True,
+def generate_long_string_hash_test(hash_factory, md, only_if=None,
skip_message=None):
def test_long_string_hash(self):
for api in _ALL_APIS:
@@ -113,7 +113,7 @@ def generate_long_string_hash_test(hash_factory, md, only_if=lambda api: True,
def long_string_hash_test(api, hash_factory, md, only_if, skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
m = hash_factory(api)
m.update(b"a" * 1000000)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index a9bb6a87..3fe9e570 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -269,6 +269,20 @@ def test_load_cryptrec_vectors():
]
+def test_load_cryptrec_vectors_invalid():
+ vector_data = textwrap.dedent("""
+ # Vectors taken from http://info.isl.ntt.co.jp/crypt/eng/camellia/
+ # Download is t_camelia.txt
+
+ # Camellia with 128-bit key
+
+ E No.001 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ """).splitlines()
+
+ with pytest.raises(ValueError):
+ load_cryptrec_vectors(vector_data)
+
+
def test_load_cryptrec_vectors_from_file_encrypt():
test_set = load_cryptrec_vectors_from_file(
"Camellia/NTT/camellia-128-ecb.txt"
diff --git a/tests/utils.py b/tests/utils.py
index 03b780f8..fa7cc68d 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -90,6 +90,8 @@ def load_cryptrec_vectors(vector_data):
"plaintext": pt,
"ciphertext": ct
})
+ else:
+ raise ValueError("Invalid line in file '{}'".format(line))
return cryptrec_list
diff --git a/tox.ini b/tox.ini
index 0a28af15..e72eb58b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@ deps =
pretend
commands =
coverage run --source=cryptography/,tests/ -m pytest
- coverage report -m
+ coverage report -m --fail-under 100
[testenv:docs]
deps = sphinx