def _dir_iter(self, dname): """Iterate over all tests in modules found in the given directory and its subdirectories. Returns an iterator of Test objects. """ for f in find_files(dname, match=self.module_pattern, direxclude=self.dir_exclude): if not basename(f).startswith(six.text_type('__init__.')): for result in self._module_iter(f): yield result
def finalize_coverage(options): if _coverobj and options.coverpkgs: rank = 0 if not options.nompi: try: from mpi4py import MPI rank = MPI.COMM_WORLD.rank except ImportError: pass if rank == 0: from testflo.util import find_files, find_module excl = lambda n: (n.startswith('test_') and n.endswith('.py')) or \ n.startswith('__init__.') dirs = [] for n in options.coverpkgs: if os.path.isdir(n): dirs.append(n) else: path = find_module(n) if path is None: raise RuntimeError("Can't find module %s" % n) dirs.append(os.path.dirname(path)) morfs = list(find_files(dirs, match='*.py', exclude=excl)) _coverobj.combine() # write combined data to default filename (as used by coveralls) # (NOTE: get_data() returns None, so using data attribute) _coverobj.data.write_file('.coverage') if options.coverage: _coverobj.report(morfs=morfs) else: dname = '_html' _coverobj.html_report(morfs=morfs, directory=dname) outfile = os.path.join(os.getcwd(), dname, 'index.html') if sys.platform == 'darwin': os.system('open %s' % outfile) else: webbrowser.get().open(outfile)