summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorAhmad A. Hussein <ahmadahussein0@gmail.com>2020-07-22 17:37:52 +0200
committerCarlton Gibson <carlton@noumenal.es>2020-08-13 17:17:15 +0200
commit61a0ba43cfd4ff66f51a9d73dcd8ed6f6a6d9915 (patch)
tree5c5033cee4d537df66a6e1a51d4ea1a285551a65 /django/core
parent21768a99f47ee73a2f93405151550ef7c3d9c8a2 (diff)
downloaddjango-61a0ba43cfd4ff66f51a9d73dcd8ed6f6a6d9915.tar.gz
Refs #31811 -- Added optional timing outputs to the test runner.
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management/commands/test.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 679dbc01ea..35e7b73871 100644
--- a/django/core/management/commands/test.py
+++ b/django/core/management/commands/test.py
@@ -3,7 +3,7 @@ import sys
from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management.utils import get_command_line_option
-from django.test.utils import get_runner
+from django.test.utils import NullTimeKeeper, TimeKeeper, get_runner
class Command(BaseCommand):
@@ -49,8 +49,10 @@ class Command(BaseCommand):
def handle(self, *test_labels, **options):
TestRunner = get_runner(settings, options['testrunner'])
+ time_keeper = TimeKeeper() if options.get('timing', False) else NullTimeKeeper()
test_runner = TestRunner(**options)
- failures = test_runner.run_tests(test_labels)
-
+ with time_keeper.timed('Total run'):
+ failures = test_runner.run_tests(test_labels)
+ time_keeper.print_results()
if failures:
sys.exit(1)