[Django] #32529: Delay creating a test suite inside DiscoverRunner.build_suite()

7 views
Skip to first unread message

Django

unread,
Mar 9, 2021, 4:58:15 AM3/9/21
to django-...@googlegroups.com
#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.

Django

unread,
Mar 9, 2021, 5:50:56 AM3/9/21
to django-...@googlegroups.com
#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,build_suite,testsuite|
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32529#comment:1>

Django

unread,
Mar 9, 2021, 7:39:27 AM3/9/21
to django-...@googlegroups.com
#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,build_suite,testsuite|
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Jerdonek):

* owner: nobody => Chris Jerdonek
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32529#comment:2>

Django

unread,
Mar 10, 2021, 2:19:41 AM3/10/21
to django-...@googlegroups.com
#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,build_suite,testsuite|
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Jerdonek):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32529#comment:3>

Django

unread,
Mar 11, 2021, 3:24:15 AM3/11/21
to django-...@googlegroups.com
#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
DiscoverRunner,build_suite,testsuite| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32529#comment:4>

Django

unread,
Mar 11, 2021, 4:52:56 AM3/11/21
to django-...@googlegroups.com
#32529: Delay creating a test suite inside DiscoverRunner.build_suite()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: closed

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
DiscoverRunner,build_suite,testsuite| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"d828beb68f6b925217242e8f4faac2216f7c9c57" d828beb6]:
{{{
#!CommitTicketReference repository=""
revision="d828beb68f6b925217242e8f4faac2216f7c9c57"
Fixed #32529 -- Delayed creating a test suite in build_suite().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32529#comment:5>

Reply all
Reply to author
Forward
0 new messages