Return iterator instead of list

Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
gabor-mezei-arm 2021-06-29 15:42:57 +02:00
parent 6385780f54
commit 0c24edd56a
No known key found for this signature in database
GPG key ID: 106F5A41ECC305BD

View file

@ -482,14 +482,12 @@ class StorageFormat:
for alg in self.constructors.generate_expressions(algorithms): for alg in self.constructors.generate_expressions(algorithms):
yield from self.keys_for_algorithm(alg) yield from self.keys_for_algorithm(alg)
def generate_all_keys(self) -> List[StorageTestData]: def generate_all_keys(self) -> Iterator[StorageTestData]:
"""Generate all keys for the test cases.""" """Generate all keys for the test cases."""
keys = [] #type: List[StorageTestData] yield from self.all_keys_for_lifetimes()
keys += self.all_keys_for_lifetimes() yield from self.all_keys_for_usage_flags()
keys += self.all_keys_for_usage_flags() yield from self.all_keys_for_types()
keys += self.all_keys_for_types() yield from self.all_keys_for_algorithms()
keys += self.all_keys_for_algorithms()
return keys
def all_test_cases(self) -> Iterator[test_case.TestCase]: def all_test_cases(self) -> Iterator[test_case.TestCase]:
"""Generate all storage format test cases.""" """Generate all storage format test cases."""
@ -621,10 +619,9 @@ class StorageFormatV0(StorageFormat):
if kt.is_valid_for_signature(usage): if kt.is_valid_for_signature(usage):
yield self.keys_for_implicit_usage(usage, alg, kt) yield self.keys_for_implicit_usage(usage, alg, kt)
def generate_all_keys(self) -> List[StorageTestData]: def generate_all_keys(self) -> Iterator[StorageTestData]:
keys = super().generate_all_keys() yield from super().generate_all_keys()
keys += self.all_keys_for_implicit_usage() yield from self.all_keys_for_implicit_usage()
return keys
class TestGenerator: class TestGenerator:
"""Generate test data.""" """Generate test data."""