#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: nobody
Jerdonek |
Type: | Status: new
Cleanup/optimization |
Component: Testing | Version: 3.1
framework | Keywords:
Severity: Normal | DiscoverRunner,build_suite,testsuite
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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)]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32529>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.c0f76a0a41a4fc23d804a71d7eefe3c8%40djangoproject.com.