Opened 3 years ago

Last modified 3 years ago

#32609 closed Cleanup/optimization

runtests.py setup should use DiscoverRunner's test label logic — at Version 1

Reported by: Chris Jerdonek Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords: DiscoverRunner, runtests
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 (last modified by Chris Jerdonek)

I noticed that runtests.py does its own rudimentary "parsing" of the provided test labels here:
https://github.com/django/django/blob/548dce50cf548e777a0c34b5485a146a0606ae73/tests/runtests.py#L128-L132

However, it would be better if it used the same logic as DiscoverRunner.build_suite():
https://github.com/django/django/blob/548dce50cf548e777a0c34b5485a146a0606ae73/django/test/runner.py#L612

There are a few reasons for this. First, it would let runtests take into account the test tags when determining which app modules apply. Second, it would centralize the test label logic, which should simplify maintenance. (For example, I was previously unaware of this code path, which explains why some things mysteriously weren't working before.) Third, it might even permit test labels to be directory paths when used with runtests.py, as a free side effect. (Currently, directory paths don't seem to work with runtests.py, I believe for this reason.) A fourth is that runtests.py will fail faster if a bad test label is passed.

Change History (1)

comment:1 by Chris Jerdonek, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top