Opened 4 years ago
Last modified 4 years ago
#32489 closed Cleanup/optimization
Add a generator function in runner.py to iterate over a test suite's test cases — at Initial Version
Reported by: | Chris Jerdonek | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | test suite, iterator, |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are four functions or methods in test/runner.py that need to iterate over a test suite's test cases:
- DiscoverRunner._get_databases()
- partition_suite_by_type()
- partition_suite_by_case()
- filter_tests_by_tags()
Each of these functions is a little harder to understand than it needs to be because each needs to contain the logic of how to iterate over a test suite, which isn't obvious. In particular, they're all implemented as recursive functions, since test suites can contain test suites.
If runner.py
contained a single helper function that accepts a test suite instance and returns an iterator of the test suite's test cases, then each of those four functions could be simplified. They could contain a simple for
loop over the iterator's return value and not have to be recursive.
The helper function would be pretty simple and could itself be recursive (but it wouldn't need to be). It could be called something like iter_test_cases(suite)
.