def alltestnames(package_or_requirement, suite, regex=None): #{{{ por = package_or_requirement if not regex: regex = _DefaultModNameRegex if ispackage(por, suite) or (isinstance(suite, basestring) and resource_isdir(por, suite)): return _atn_gen(por, suite, regex) raise TypeError('Cannot walk through sub packages/modules of %s object' %suite.__class__.__name__)
def alltestobjects(package_or_requirement, suite, regex=None): #{{{ por = package_or_requirement if not regex: regex = _DefaultModNameRegex if ispackage(por, suite) or (isinstance(suite, basestring) and resource_isdir(suite)): return _ato_gen(por, suite, regex) raise TypeError("%s object is not a package" %suite.__class__.__name__)
def allrstfiles(package_or_requirement, dir): #{{{ por = package_or_requirement if not resource_isdir(por, dir): raise OSError("No such directory: %s" %dir) for root, dirs, files in resource_walk(por, dir): for f in files: name, ext = op.splitext(f) if ext == '.rst': yield f return
def isfilemodule(package_or_resource, obj): #{{{ por, isfile = package_or_resource, resource_isfile try: assert ismodule(por, obj) name, ind = obj.__name__, 0 if isinstance(por, basestring): ind = 1 path = pp.join(pp.sep, *name.split('.')[ind:]) check = [] if resource_isdir(por, path): check.append(pp.join(path, '__init__')) check.append(path) ext = ['py'+c for c in ('', 'c', 'o')] assert any(isfile(por, '.'.join([p, pext])) for pext in ext for p in check) except AssertionError: return False return True