Opened 6 years ago
Closed 6 years ago
#30245 closed New feature (fixed)
Run tests matching a filter (Python 3.7 -k option)
Reported by: | François Freitag | Owned by: | François Freitag |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | test, unittest, filter |
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
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 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 running tests by keyword expression. The feature is also available in other testing frameworks, such as PHPUnit
's --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
?
Change History (8)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
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 preferable.
"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!
comment:3 by , 6 years ago
Hi Carlton,
Thank you for looking into this ticket. I'll present the case to the mailing list today or tomorrow.
Cheers,
comment:4 by , 6 years ago
Patch needs improvement: | set |
---|
Marking "Patch needs improvement" until we hear back from the mailing list discussion.
comment:5 by , 6 years ago
Mailing list thread: https://groups.google.com/forum/#!topic/django-developers/6NcMRULpBYw
comment:6 by , 6 years ago
Patch needs improvement: | unset |
---|
Following mailing list consensus to remove the -k
shorthand for --keepdb
without replacement, the PR has been updated and uses -k
to select tests.
comment:7 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR