mirror of
https://github.com/django/django.git
synced 2025-08-19 02:01:29 +00:00
Fixed #34210 -- Added unittest's durations option to the test runner.
This commit is contained in:
parent
27b399d235
commit
74b5074174
8 changed files with 110 additions and 5 deletions
|
@ -33,6 +33,7 @@ else:
|
|||
RemovedInDjango60Warning,
|
||||
)
|
||||
from django.utils.log import DEFAULT_LOGGING
|
||||
from django.utils.version import PY312
|
||||
|
||||
try:
|
||||
import MySQLdb
|
||||
|
@ -380,6 +381,7 @@ def django_tests(
|
|||
buffer,
|
||||
timing,
|
||||
shuffle,
|
||||
durations=None,
|
||||
):
|
||||
if parallel in {0, "auto"}:
|
||||
max_parallel = get_max_test_processes()
|
||||
|
@ -425,6 +427,7 @@ def django_tests(
|
|||
buffer=buffer,
|
||||
timing=timing,
|
||||
shuffle=shuffle,
|
||||
durations=durations,
|
||||
)
|
||||
failures = test_runner.run_tests(test_labels)
|
||||
teardown_run_tests(state)
|
||||
|
@ -688,6 +691,15 @@ if __name__ == "__main__":
|
|||
"Same as unittest -k option. Can be used multiple times."
|
||||
),
|
||||
)
|
||||
if PY312:
|
||||
parser.add_argument(
|
||||
"--durations",
|
||||
dest="durations",
|
||||
type=int,
|
||||
default=None,
|
||||
metavar="N",
|
||||
help="Show the N slowest test cases (N=0 for all).",
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
|
@ -785,6 +797,7 @@ if __name__ == "__main__":
|
|||
options.buffer,
|
||||
options.timing,
|
||||
options.shuffle,
|
||||
getattr(options, "durations", None),
|
||||
)
|
||||
time_keeper.print_results()
|
||||
if failures:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue