diff options
author | David Reid <dreid@dreid.org> | 2013-11-11 14:40:05 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2013-11-11 14:40:05 -0800 |
commit | a3d71d471856e6c76cc1cc543efecb504dbe5c33 (patch) | |
tree | 6658c10105765ad9681f311bb5c5eee14f8010c2 /tests | |
parent | 1aefe584a2c5c4f6bbf2839184868b16bdb9dc0b (diff) | |
parent | 521c42d26ca164050745a9d33c0e3b7785341bf5 (diff) | |
download | cryptography-a3d71d471856e6c76cc1cc543efecb504dbe5c33.tar.gz cryptography-a3d71d471856e6c76cc1cc543efecb504dbe5c33.tar.bz2 cryptography-a3d71d471856e6c76cc1cc543efecb504dbe5c33.zip |
Merge pull request #240 from alex/cleanup
Simplify the code by doing the filtering earlier, rather than later
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/utils.py b/tests/utils.py index 99ba2e2f..cc56a9ac 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -15,7 +15,9 @@ import os.path def load_nist_vectors(vector_data, op): - section, count, data = None, None, {} + section = None + count = None + data = {} for line in vector_data: line = line.strip() @@ -31,7 +33,9 @@ def load_nist_vectors(vector_data, op): # Look for section headers if line.startswith("[") and line.endswith("]"): section = line[1:-1] - data[section] = {} + continue + + if section != op: continue # Build our data using a simple Key = Value format @@ -40,15 +44,15 @@ def load_nist_vectors(vector_data, op): # COUNT is a special token that indicates a new block of data if name.upper() == "COUNT": count = value - data[section][count] = {} + data[count] = {} # For all other tokens we simply want the name, value stored in # the dictionary else: - data[section][count][name.lower()] = value.encode("ascii") + data[count][name.lower()] = value.encode("ascii") # We want to test only for a particular operation, we sort them for the # benefit of the tests of this function. - return [v for k, v in sorted(data[op].items(), key=lambda kv: kv[0])] + return [v for k, v in sorted(data.items(), key=lambda kv: kv[0])] def load_nist_vectors_from_file(filename, op): |