[Django] #30245: Run tests matching a filter (Python 3.7 -k option)

9 views
Skip to first unread message

Django

unread,
Mar 9, 2019, 9:36:36 AM3/9/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François | Owner: François Freitag
Freitag |
Type: New | Status: assigned
feature |
Component: Testing | Version: master
framework | Keywords:
Severity: Normal | test,unittest,filter
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With Python 3.7, the `unittest` module got a `-k` option (as in keyword),
to run tests matching a given keyword. Corresponding entry in the
[https://docs.python.org/3.7/whatsnew/3.7.html#unittest Python 3.7
unittest release note entry]. Associated python issue:
https://bugs.python.org/issue32071.

The feature seems to be coming from the `py.test` project feature
[https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-
tests running tests by keyword expression]. The feature is also available
in other testing frameworks, such as `PHPUnit`'s
[https://phpunit.de/manual/6.5/en/textui.html --filter] option.

Adding a similar feature to Django would facilitate test selection. Since
`-k` is already the short-hand for `--keepdb`, it may make more sense to
implement another flag, maybe `--filter`?

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

Django

unread,
Mar 9, 2019, 9:42:17 AM3/9/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
test,unittest,filter | Unreviewed
Has patch: 1 | Needs documentation: 0

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

Comment (by François Freitag):

[https://github.com/django/django/pull/11067 PR]

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

Django

unread,
Mar 11, 2019, 4:04:56 AM3/11/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
test,unittest,filter |
Has patch: 1 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Comment:

Hi François. Yes, this seems a good addition to me.

> ... `-k` is already the short-hand for ...

My initial thought here would be to ''re-take'' `-k` to match `unittest`.
I'm pretty sure us having contrary flags is just going to be a royal-pain
forever.
A small-BC change there is preferably.

"We're adding `-k` to mean ... following `unittest`. Use long `--keepdb`
flag instead." — but maybe people want a short flag too. (???)

I guess we need to ask on the DevelopersMailingList. Can I ask you to post
there to begin the discussion? (I can do it if you don't have a moment.)

Thanks!

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

Django

unread,
Mar 11, 2019, 4:39:43 AM3/11/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
test,unittest,filter |
Has patch: 1 | Needs documentation: 0

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

Comment (by François Freitag):

Hi Carlton,

Thank you for looking into this ticket. I'll present the case to the
mailing list today or tomorrow.

Cheers,

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

Django

unread,
Mar 11, 2019, 5:57:19 AM3/11/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
test,unittest,filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


Comment:

Marking "Patch needs improvement" until we hear back from the mailing list
discussion.

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

Django

unread,
Mar 11, 2019, 8:19:03 AM3/11/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
test,unittest,filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by François Freitag):

Mailing list thread: https://groups.google.com/forum/#!topic/django-
developers/6NcMRULpBYw

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

Django

unread,
Mar 12, 2019, 9:44:52 AM3/12/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
test,unittest,filter |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by François Freitag):

* needs_better_patch: 1 => 0


Comment:

Following mailing list consensus to remove the `-k` shorthand for
`--keepdb` without replacement, the
[https://github.com/django/django/pull/11067 PR] has been updated and uses
`-k` to select tests.

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

Django

unread,
Apr 26, 2019, 7:28:04 PM4/26/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
test,unittest,filter | checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Apr 30, 2019, 10:42:02 AM4/30/19
to django-...@googlegroups.com
#30245: Run tests matching a filter (Python 3.7 -k option)
-------------------------------------+-------------------------------------
Reporter: François Freitag | Owner: François
| Freitag
Type: New feature | Status: closed

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

Keywords: | Triage Stage: Ready for
test,unittest,filter | 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:"568eed9e79470b9ddf3e1b3bbad9123ada45eae8" 568eed9]:
{{{
#!CommitTicketReference repository=""
revision="568eed9e79470b9ddf3e1b3bbad9123ada45eae8"
Fixed #30245 -- Added -k option to DiscoverRunner.
}}}

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

Reply all
Reply to author
Forward
0 new messages