mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-06-25 12:41:56 +03:00
Split generate_tests to reduce code complexity
Previous implementation mixed the test case generation and the recursive generation calls together. A separate method is added to generate test cases for the current class' test function. This reduces the need to override generate_tests(). Signed-off-by: Werner Lewis <werner.lewis@arm.com>
This commit is contained in:
@ -160,14 +160,10 @@ class BignumOperation(BignumTarget, metaclass=ABCMeta):
|
||||
yield from cls.input_cases
|
||||
|
||||
@classmethod
|
||||
def generate_tests(cls) -> Iterator[test_case.TestCase]:
|
||||
if cls.test_function:
|
||||
# Generate tests for the current class
|
||||
for l_value, r_value in cls.get_value_pairs():
|
||||
cur_op = cls(l_value, r_value)
|
||||
yield cur_op.create_test_case()
|
||||
# Once current class completed, check descendants
|
||||
yield from super().generate_tests()
|
||||
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
|
||||
for l_value, r_value in cls.get_value_pairs():
|
||||
cur_op = cls(l_value, r_value)
|
||||
yield cur_op.create_test_case()
|
||||
|
||||
|
||||
class BignumCmp(BignumOperation):
|
||||
|
Reference in New Issue
Block a user