From f7f6a9f77ade1b190766c37cc8967375b5093175 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 11 Nov 2013 20:43:52 -0600 Subject: Remove separate file loaders and replace with one All tests updated to work with the new simplified loader --- tests/utils.py | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 0b215543..df9232d8 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -14,6 +14,14 @@ import os.path +def load_vectors_from_file(filename, loader): + base = os.path.join( + os.path.dirname(__file__), "hazmat", "primitives", "vectors", + ) + with open(os.path.join(base, filename), "r") as vector_file: + return loader(vector_file) + + def load_nist_vectors(vector_data): section = None count = None @@ -52,23 +60,6 @@ def load_nist_vectors(vector_data): return [v for k, v in sorted(data.items(), key=lambda kv: kv[0])] -def load_nist_vectors_from_file(filename): - base = os.path.join( - os.path.dirname(__file__), "hazmat", "primitives", "vectors", - ) - with open(os.path.join(base, filename), "r") as vector_file: - return load_nist_vectors(vector_file) - - -def load_cryptrec_vectors_from_file(filename): - base = os.path.join( - os.path.dirname(__file__), - "hazmat", "primitives", "vectors", - ) - with open(os.path.join(base, filename), "r") as vector_file: - return load_cryptrec_vectors(vector_file) - - def load_cryptrec_vectors(vector_data): cryptrec_list = [] @@ -97,15 +88,6 @@ def load_cryptrec_vectors(vector_data): return cryptrec_list -def load_openssl_vectors_from_file(filename): - base = os.path.join( - os.path.dirname(__file__), - "hazmat", "primitives", "vectors", - ) - with open(os.path.join(base, filename), "r") as vector_file: - return load_openssl_vectors(vector_file) - - def load_openssl_vectors(vector_data): vectors = [] @@ -167,11 +149,3 @@ def load_hash_vectors(vector_data): else: raise ValueError("Unknown line in hash vector") return vectors - - -def load_hash_vectors_from_file(filename): - base = os.path.join( - os.path.dirname(__file__), "hazmat", "primitives", "vectors" - ) - with open(os.path.join(base, filename), "r") as vector_file: - return load_hash_vectors(vector_file) -- cgit v1.2.3