def _trialSortAlgorithm(self, sorter): """ Right now, halfway by accident, trial sorts like this: 1. all modules are grouped together in one list and sorted. 2. within each module, the classes are grouped together in one list and sorted. 3. finally within each class, each test method is grouped together in a list and sorted. This attempts to return a sorted list of testable thingies following those rules, so that we can compare the behavior of loadPackage. The things that show as 'cases' are errors from modules which failed to import, and test methods. Let's gather all those together. """ pkg = getModule('uberpackage') testModules = [] for testModule in pkg.walkModules(): if testModule.name.split(".")[-1].startswith("test_"): testModules.append(testModule) sortedModules = util.dsu(testModules, sorter) # ONE for modinfo in sortedModules: # Now let's find all the classes. module = modinfo.load(None) if module is None: yield modinfo else: testClasses = [] for attrib in modinfo.iterAttributes(): if runner.isTestCase(attrib.load()): testClasses.append(attrib) sortedClasses = util.dsu(testClasses, sorter) # TWO for clsinfo in sortedClasses: testMethods = [] for attr in clsinfo.iterAttributes(): if attr.name.split(".")[-1].startswith('test'): testMethods.append(attr) sortedMethods = util.dsu(testMethods, sorter) # THREE for methinfo in sortedMethods: yield methinfo
def _trialSortAlgorithm(self, sorter): """ Right now, halfway by accident, trial sorts like this: 1. all modules are grouped together in one list and sorted. 2. within each module, the classes are grouped together in one list and sorted. 3. finally within each class, each test method is grouped together in a list and sorted. This attempts to return a sorted list of testable thingies following those rules, so that we can compare the behavior of loadPackage. The things that show as 'cases' are errors from modules which failed to import, and test methods. Let's gather all those together. """ pkg = getModule('uberpackage') testModules = [] for testModule in pkg.walkModules(): if testModule.name.split(".")[-1].startswith("test_"): testModules.append(testModule) sortedModules = sorted(testModules, key=sorter) # ONE for modinfo in sortedModules: # Now let's find all the classes. module = modinfo.load(None) if module is None: yield modinfo else: testClasses = [] for attrib in modinfo.iterAttributes(): if runner.isTestCase(attrib.load()): testClasses.append(attrib) sortedClasses = sorted(testClasses, key=sorter) # TWO for clsinfo in sortedClasses: testMethods = [] for attr in clsinfo.iterAttributes(): if attr.name.split(".")[-1].startswith('test'): testMethods.append(attr) sortedMethods = sorted(testMethods, key=sorter) # THREE for methinfo in sortedMethods: yield methinfo