def loadTree(self, name=None): ''' Loads tests into a tree from the given directory of the specified name. ''' tree = {} errors = [] loaded = False location.clear() for mdl in sorted(location.getSuites(), reverse=True): if name: if (name != mdl and not name.startswith(mdl + '.') and not mdl.startswith(name + '.')): continue loaded = True parts = mdl.split('.') branch = tree for nm in parts: if nm not in branch: branch[nm] = {} branch = branch[nm] nm = name[len(mdl) + 1:] if name and len(name) > len(mdl) else None branch[None], merrs = self.loadFromModule(mdl, nm and [nm]) errors.extend(merrs) if name and len(name) >= len(mdl): break if name and not loaded: errors = self.loadFromModule(name)[1] return tree, errors
def loadTree(self, name=None): ''' Loads tests into a tree from the given directory of the specified name. ''' tree = {} errors = [] loaded = False location.clear() for mdl in sorted(location.getSuites(), reverse=True): if name: if (name != mdl and not name.startswith(mdl + '.') and not mdl.startswith(name + '.')): continue loaded = True parts = mdl.split('.') branch = tree for nm in parts: if nm not in branch: branch[nm] = {} branch = branch[nm] nm = name[len(mdl)+1:] if name and len(name) > len(mdl) else None branch[None], merrs = self.loadFromModule(mdl, nm and [nm]) errors.extend(merrs) if name and len(name) >= len(mdl): break if name and not loaded: errors = self.loadFromModule(name)[1] return tree, errors
def loadFromNames(self, *names): ''' Loads tests of the given names. ''' location.clear() # Make sure that all names are not related tests = [] errors = [] names = names or None if names: nms = [] for name in names: name = name.strip().strip('.') if not name: continue ok = True for nm in nms[:]: if name == nm or name.startswith(nm + '.'): ok = False break if nm.startswith(name + '.'): nms.remove(nm) if ok: nms.append(name) names = nms # Load tests from given names modules = {} for mdl in sorted(location.getSuites(), reverse=True): if names is None: modules[mdl] = None else: for name in names[:]: if mdl == name or mdl.startswith(name + '.'): modules[mdl] = None if mdl == name: names.remove(name) elif name.startswith(mdl + '.'): if mdl not in modules: modules[mdl] = [] modules[mdl].append(name[len(mdl) + 1:]) names.remove(name) if names: for name in names: modules[name] = None for mdl, nms in modules.iteritems(): mtests, merrs = self.loadFromModule(mdl, nms) tests.extend(mtests) errors.extend(merrs) return tests, errors
def loadFromNames(self, *names): ''' Loads tests of the given names. ''' location.clear() # Make sure that all names are not related tests = [] errors = [] names = names or None if names: nms = [] for name in names: name = name.strip().strip('.') if not name: continue ok = True for nm in nms[:]: if name == nm or name.startswith(nm + '.'): ok = False break if nm.startswith(name + '.'): nms.remove(nm) if ok: nms.append(name) names = nms # Load tests from given names modules = {} for mdl in sorted(location.getSuites(), reverse=True): if names is None: modules[mdl] = None else: for name in names[:]: if mdl == name or mdl.startswith(name + '.'): modules[mdl] = None if mdl == name: names.remove(name) elif name.startswith(mdl + '.'): if mdl not in modules: modules[mdl] = [] modules[mdl].append(name[len(mdl)+1:]) names.remove(name) if names: for name in names: modules[name] = None for mdl, nms in modules.iteritems(): mtests, merrs = self.loadFromModule(mdl, nms) tests.extend(mtests) errors.extend(merrs) return tests, errors