Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions django_slowtests/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

from unittest import TestSuite
from django.test.runner import DiscoverRunner
from django.conf import settings


TIMINGS = {}
NUM_SLOW_TESTS = getattr(settings, 'NUM_SLOW_TESTS', 10)


def time_it(func):
Expand Down Expand Up @@ -47,7 +49,7 @@ def teardown_test_environment(self, **kwargs):
iter(TIMINGS.items()),
key=operator.itemgetter(1),
reverse=True
)[:10]
print("\nTen slowest tests:")
)[:NUM_SLOW_TESTS]
print("\n%s slowest tests:" % NUM_SLOW_TESTS)
for func_name, timing in by_time:
print(("{t:.4f}s {f}".format(f=func_name, t=timing)))