Refs #32489 -- Removed unneeded partition_suite_by_type().
This commit is contained in:
parent
2e5aa444d1
commit
cc12894017
|
@ -766,7 +766,7 @@ def is_discoverable(label):
|
||||||
|
|
||||||
def reorder_suite(suite, classes, reverse=False):
|
def reorder_suite(suite, classes, reverse=False):
|
||||||
"""
|
"""
|
||||||
Reorder a test suite by test type.
|
Reorder a test suite by test type, removing any duplicates.
|
||||||
|
|
||||||
`classes` is a sequence of types
|
`classes` is a sequence of types
|
||||||
|
|
||||||
|
@ -776,34 +776,19 @@ def reorder_suite(suite, classes, reverse=False):
|
||||||
If `reverse` is True, sort tests within classes in opposite order but
|
If `reverse` is True, sort tests within classes in opposite order but
|
||||||
don't reverse test classes.
|
don't reverse test classes.
|
||||||
"""
|
"""
|
||||||
class_count = len(classes)
|
bins = [OrderedSet() for i in range(len(classes) + 1)]
|
||||||
suite_class = type(suite)
|
*class_bins, last_bin = bins
|
||||||
bins = [OrderedSet() for i in range(class_count + 1)]
|
|
||||||
partition_suite_by_type(suite, classes, bins, reverse=reverse)
|
|
||||||
reordered_suite = suite_class()
|
|
||||||
for tests in bins:
|
|
||||||
reordered_suite.addTests(tests)
|
|
||||||
return reordered_suite
|
|
||||||
|
|
||||||
|
|
||||||
def partition_suite_by_type(suite, classes, bins, reverse=False):
|
|
||||||
"""
|
|
||||||
Partition a test suite by test type. Also prevent duplicated tests.
|
|
||||||
|
|
||||||
classes is a sequence of types
|
|
||||||
bins is a sequence of TestSuites, one more than classes
|
|
||||||
reverse changes the ordering of tests within bins
|
|
||||||
|
|
||||||
Tests of type classes[i] are added to bins[i],
|
|
||||||
tests with no match found in classes are place in bins[-1]
|
|
||||||
"""
|
|
||||||
for test in iter_test_cases(suite, reverse=reverse):
|
for test in iter_test_cases(suite, reverse=reverse):
|
||||||
for i in range(len(classes)):
|
for test_bin, test_class in zip(class_bins, classes):
|
||||||
if isinstance(test, classes[i]):
|
if isinstance(test, test_class):
|
||||||
bins[i].add(test)
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
bins[-1].add(test)
|
test_bin = last_bin
|
||||||
|
test_bin.add(test)
|
||||||
|
|
||||||
|
suite_class = type(suite)
|
||||||
|
return suite_class(itertools.chain(*bins))
|
||||||
|
|
||||||
|
|
||||||
def partition_suite_by_case(suite):
|
def partition_suite_by_case(suite):
|
||||||
|
|
Loading…
Reference in New Issue