MCPcopy
hub / github.com/django/django / build_suite

Method build_suite

django/test/runner.py:963–1022  ·  view source on GitHub ↗
(self, test_labels=None, **kwargs)

Source from the content-addressed store, hash-verified

961 return tests
962
963 def build_suite(self, test_labels=None, **kwargs):
964 test_labels = test_labels or ["."]
965
966 discover_kwargs = {}
967 if self.pattern is not None:
968 discover_kwargs["pattern"] = self.pattern
969 if self.top_level is not None:
970 discover_kwargs["top_level_dir"] = self.top_level
971 self.setup_shuffler()
972
973 all_tests = []
974 for label in test_labels:
975 tests = self.load_tests_for_label(label, discover_kwargs)
976 all_tests.extend(iter_test_cases(tests))
977
978 if self.tags or self.exclude_tags:
979 if self.tags:
980 self.log(
981 "Including test tag(s): %s." % ", ".join(sorted(self.tags)),
982 level=logging.DEBUG,
983 )
984 if self.exclude_tags:
985 self.log(
986 "Excluding test tag(s): %s." % ", ".join(sorted(self.exclude_tags)),
987 level=logging.DEBUG,
988 )
989 all_tests = filter_tests_by_tags(all_tests, self.tags, self.exclude_tags)
990
991 # Put the failures detected at load time first for quicker feedback.
992 # _FailedTest objects include things like test modules that couldn't be
993 # found or that couldn't be loaded due to syntax errors.
994 test_types = (unittest.loader._FailedTest, *self.reorder_by)
995 all_tests = list(
996 reorder_tests(
997 all_tests,
998 test_types,
999 shuffler=self._shuffler,
1000 reverse=self.reverse,
1001 )
1002 )
1003 self.log("Found %d test(s)." % len(all_tests))
1004 suite = self.test_suite(all_tests)
1005
1006 if self.parallel > 1:
1007 subsuites = partition_suite_by_case(suite)
1008 # Since tests are distributed across processes on a per-TestCase
1009 # basis, there's no need for more processes than TestCases.
1010 processes = min(self.parallel, len(subsuites))
1011 # Update also "parallel" because it's used to determine the number
1012 # of test databases.
1013 self.parallel = processes
1014 if processes > 1:
1015 suite = self.parallel_test_suite(
1016 subsuites,
1017 processes,
1018 self.failfast,
1019 self.debug_mode,
1020 self.buffer,

Calls 9

setup_shufflerMethod · 0.95
load_tests_for_labelMethod · 0.95
logMethod · 0.95
iter_test_casesFunction · 0.90
filter_tests_by_tagsFunction · 0.85
reorder_testsFunction · 0.85
partition_suite_by_caseFunction · 0.85
extendMethod · 0.80
joinMethod · 0.45