7
7
from django .core .exceptions import ImproperlyConfigured
8
8
from django .test import SimpleTestCase , TestCase
9
9
from django .test .utils import setup_test_environment , teardown_test_environment
10
+ from django .utils .datastructures import OrderedSet
10
11
11
12
12
13
class DiscoverRunner (object ):
@@ -231,11 +232,12 @@ def reorder_suite(suite, classes, reverse=False):
231
232
"""
232
233
class_count = len (classes )
233
234
suite_class = type (suite )
234
- bins = [suite_class () for i in range (class_count + 1 )]
235
+ bins = [OrderedSet () for i in range (class_count + 1 )]
235
236
partition_suite (suite , classes , bins , reverse = reverse )
236
- for i in range (class_count ):
237
- bins [0 ].addTests (bins [i + 1 ])
238
- return bins [0 ]
237
+ reordered_suite = suite_class ()
238
+ for i in range (class_count + 1 ):
239
+ reordered_suite .addTests (bins [i ])
240
+ return reordered_suite
239
241
240
242
241
243
def partition_suite (suite , classes , bins , reverse = False ):
@@ -258,12 +260,10 @@ def partition_suite(suite, classes, bins, reverse=False):
258
260
else :
259
261
for i in range (len (classes )):
260
262
if isinstance (test , classes [i ]):
261
- if test not in bins [i ]:
262
- bins [i ].addTest (test )
263
+ bins [i ].add (test )
263
264
break
264
265
else :
265
- if test not in bins [- 1 ]:
266
- bins [- 1 ].addTest (test )
266
+ bins [- 1 ].add (test )
267
267
268
268
269
269
def setup_databases (verbosity , interactive , keepdb = False , ** kwargs ):
0 commit comments