8000 Fixed #23992 -- Optimized reorder_suite functions using OrderedSet by tchaumeny · Pull Request #3730 · django/django · GitHub
[go: up one dir, main page]

Skip to content

Fixed #23992 -- Optimized reorder_suite functions using OrderedSet #3730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

10000

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2014
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
16 changes: 8 additions & 8 deletions django/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase, TestCase
from django.test.utils import setup_test_environment, teardown_test_environment
from django.utils.datastructures import OrderedSet


class DiscoverRunner(object):
Expand Down Expand Up @@ -231,11 +232,12 @@ def reorder_suite(suite, classes, reverse=False):
"""
class_count = len(classes)
suite_class = type(suite)
bins = [suite_class() for i in range(class_count + 1)]
bins = [OrderedSet() for i in range(class_count + 1)]
partition_suite(suite, classes, bins, reverse=reverse)
for i in range(class_count):
bins[0].addTests(bins[i + 1])
return bins[0]
reordered_suite = suite_class()
for i in range(class_count + 1):
reordered_suite.addTests(bins[i])
return reordered_suite


def partition_suite(suite, classes, bins, reverse=False):
Expand All @@ -258,12 +260,10 @@ def partition_suite(suite, classes, bins, reverse=False):
else:
for i in range(len(classes)):
if isinstance(test, classes[i]):
if test not in bins[i]:
bins[i].addTest(test)
bins[i].add(test)
break
else:
if test not in bins[-1]:
bins[-1].addTest(test)
bins[-1].add(test)


def setup_databases(verbosity, interactive, keepdb=False, **kwargs):
Expand Down
0