Opened 3 months ago

Last modified 2 months ago

#31621 assigned New feature

Add "--parallel=auto" option to the "test" command.

Reported by: Adam (Chainz) Johnson Owned by: Adam (Chainz) Johnson
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Sergey Fedoseev Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The --parallel flag to test is used as a binary "on" to mean "on all cores." But it also tries to parse the value after it as a number. This is annoying as there's no easy way to alias it as "on", since when adding a test name afterwards it is parsed as an integer:

$ python manage.py test --parallel example.core.tests.test_a
usage: manage.py test [-h] [--noinput] [--failfast] ...
manage.py test: error: argument --parallel: invalid int value: 'example.core.tests.test_a'

Pytest's xdist plugin supports the value "auto" to mean "all cores." I suggest we copy that.

Change History (6)

comment:1 Changed 3 months ago by Adam (Chainz) Johnson

Has patch: set

comment:2 Changed 3 months ago by felixxm

Owner: changed from nobody to Adam (Chainz) Johnson
Summary: Add ability to specify "all cores" to "test --parallel"Add "--parallel=auto" option to the "test" command.
Triage Stage: UnreviewedAccepted
Type: Cleanup/optimizationNew feature

comment:3 Changed 3 months ago by Ahmad A. Hussein

Triage Stage: AcceptedReady for checkin

Patch looks good

comment:4 Changed 3 months ago by felixxm

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:5 Changed 2 months ago by Sergey Fedoseev

Cc: Sergey Fedoseev added

What about this?

$ python manage.py test --parallel -- example.core.tests.test_a

comment:6 Changed 2 months ago by Adam (Chainz) Johnson

That works. However if you use it in e.g. an alias with alias test='python manage.py test --parallel --', then you can no longer pass extra flags.

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