Opened 4 years ago
Closed 4 years ago
#32529 closed Cleanup/optimization (fixed)
Delay creating a test suite inside DiscoverRunner.build_suite()
Reported by: | Chris Jerdonek | Owned by: | Chris Jerdonek |
---|---|---|---|
Component: | Testing framework | Version: | 3.1 |
Severity: | Normal | Keywords: | DiscoverRunner, build_suite, testsuite |
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
I noticed that DiscoverRunner.build_suite() internally uses a test suite to successively build up its test suite return value. However, build_suite()
could be simplified slightly by using a list internally and creating the suite only later towards the end.
One benefit of this is that two of the helper functions that build_suite()
calls, namely filter_tests_by_tags()
and reorder_suite()
, could be updated to operate on simple lists. This would reduce the amount of code that needs to know about test suites and their special handling.
For example, filter_tests_by_tags()
could change from this:
def filter_tests_by_tags(suite, tags, exclude_tags): suite_class = type(suite) return suite_class( test for test in iter_test_cases(suite) if test_match_tags(test, tags, exclude_tags) )
to this:
def filter_tests_by_tags(tests, tags, exclude_tags): return [test for test in tests if test_match_tags(test, tags, exclude_tags)]
Change History (5)
comment:1 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR