[Django] #32609: runtests.py setup should use DiscoverRunner's test label logic

1 view
Skip to first unread message

Django

unread,
Mar 31, 2021, 8:21:03 PM3/31/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: nobody
Jerdonek |
Type: | Status: new
Cleanup/optimization |
Component: Testing | Version: dev
framework | Keywords:
Severity: Normal | DiscoverRunner,runtests
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 `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.)

--
Ticket URL: <https://code.djangoproject.com/ticket/32609>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 31, 2021, 9:29:06 PM3/31/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
DiscoverRunner,runtests | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Chris Jerdonek:

Old description:

> 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.)

New description:

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.

--

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

Django

unread,
Mar 31, 2021, 9:35:42 PM3/31/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: | Status: new
Cleanup/optimization |

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

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

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 2, 2021, 8:55:54 AM4/2/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned

Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
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/32609#comment:3>

Django

unread,
Apr 17, 2021, 8:29:54 AM4/17/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
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


Comment:

Here is a first PR: https://github.com/django/django/pull/14276

I want to wait until #32611 is resolved before doing more because there is
overlap, but this is a good change to make in isolation.

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

Django

unread,
Apr 19, 2021, 5:02:03 AM4/19/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"413c15ef2e3d3958fb641a023bc1e2d15fb2b228" 413c15ef]:
{{{
#!CommitTicketReference repository=""
revision="413c15ef2e3d3958fb641a023bc1e2d15fb2b228"
Refs #32609 -- Simplified test_labels_set construction in runtests.py's
setup().

Follow up to 7cf3a5786bc76374e743fbc0c1a1c8470a61f6c0.
}}}

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

Django

unread,
Apr 19, 2021, 5:02:15 AM4/19/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
Has patch: 0 | Needs documentation: 0

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

* has_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32609#comment:6>

Django

unread,
Jun 9, 2021, 6:22:52 AM6/9/21
to django-...@googlegroups.com
#32609: runtests.py setup should use DiscoverRunner's test label logic
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
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


Comment:

PR: https://github.com/django/django/pull/14507

This PR isn't the approach I had planned when filing this ticket, but it
achieves the main part of what I was after, which is this part of my
original comment:

> 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.)

In other words, it fixes this issue that Carlton encountered when running
`runtests.py`:
https://github.com/django/django/pull/14180#pullrequestreview-624099857

As for the rest of the points, I'm not sure any longer if it's possible or
desirable to call `DiscoverRunner.build_suite()`s logic from within
`runtests.py`. The reason is that there's a bootstrapping issue: To load
tests you need to do `runtests.py`'s setup, but to do `runtests.py`'s
setup, you first have to know what the needed test modules are. This is
after developing a better understanding of `runtests.py` in the course of
working on #32668.

--
Ticket URL: <https://code.djangoproject.com/ticket/32609#comment:7>

Django

unread,
Jun 10, 2021, 2:26:43 AM6/10/21
to django-...@googlegroups.com
#32609: Added runtests.py support for directory path test labels.

-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
DiscoverRunner,runtests |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/32609#comment:8>

Django

unread,
Jun 10, 2021, 3:00:02 AM6/10/21
to django-...@googlegroups.com
#32609: Added runtests.py support for directory path test labels.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
DiscoverRunner,runtests | 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/32609#comment:9>

Django

unread,
Jun 11, 2021, 12:44:29 AM6/11/21
to django-...@googlegroups.com
#32609: Added runtests.py support for directory path test labels.
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: closed

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

Keywords: | Triage Stage: Ready for
DiscoverRunner,runtests | 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:"de4f6201835043ba664e8dcbdceffc4b0955ce29" de4f620]:
{{{
#!CommitTicketReference repository=""
revision="de4f6201835043ba664e8dcbdceffc4b0955ce29"
Fixed #32609 -- Updated runtests.py to support directory path test labels.

For example, with this change, the following now works from the tests
directory:

$ ./runtests.py view_tests/tests/
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32609#comment:10>

Reply all
Reply to author
Forward
0 new messages