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 François Freitag, 6 years ago

comment:2 by Carlton Gibson, 6 years ago

Triage Stage: UnreviewedAccepted

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!

Last edited 6 years ago by Carlton Gibson (previous) (diff)

comment:3 by François Freitag, 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 Carlton Gibson, 6 years ago

Patch needs improvement: set

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

comment:6 by François Freitag, 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 Jon Dufresne, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 568eed9:

Fixed #30245 -- Added -k option to DiscoverRunner.

Note: See TracTickets for help on using tickets.
Back to Top