﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32529	Delay creating a test suite inside DiscoverRunner.build_suite()	Chris Jerdonek	Chris Jerdonek	"I noticed that [https://github.com/django/django/blob/d9a266d657f66b8c4fa068408002a4e3709ee669/django/test/runner.py#L555 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:

{{{#!python
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:

{{{#!python
def filter_tests_by_tags(tests, tags, exclude_tags):
    return [test for test in tests if test_match_tags(test, tags, exclude_tags)]
}}}
"	Cleanup/optimization	closed	Testing framework	3.1	Normal	fixed	DiscoverRunner,build_suite,testsuite		Ready for checkin	1	0	0	0	0	0
