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:
Werner Lewis 2022-08-24 12:42:00 +01:00
parent 699e126942
commit 2b527a394d
2 changed files with 28 additions and 17 deletions

View file

@ -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):