def multitest(): """ Run tests in multiple processes. """ import numba.unittest_support as unittest import multiprocessing as mp loader = unittest.TestLoader() startdir = "numba.tests" suites = loader.discover(startdir) tests = _flatten_suite(suites) # Distribute tests to multiple processes pool = mp.Pool(processes=mp.cpu_count()) results = pool.imap_unordered(_multiruntest, tests) errct = 0 for ok, out in results: if not ok: print() print("=== Error ===") print(out) errct += 1 else: print('.', end='') sys.stdout.flush() print() if errct == 0: print("All passed!") return True else: print("Error %d/%d" % (errct, len(tests))) return False
def discover_tests(startdir): """Discover test under a directory """ loader = unittest.TestLoader() suite = loader.discover(startdir) return suite
def _do_discovery(self, argv, Loader=None): """The discovery process is complicated by the fact that: * different test suites live under different directories * some test suites may not be available (CUDA) * some tests may have to be run serially, even in the presence of the '-m' flag.""" from numba import cuda join = os.path.join loader = unittest.TestLoader() if Loader is None else Loader() topdir = os.path.abspath(join(os.path.dirname(__file__), '../..')) base_tests = loader.discover(join(topdir, 'numba/tests'), 'test*.py', topdir) cuda_tests = [ loader.discover(join(topdir, 'numba/cuda/tests/nocuda'), 'test*.py', topdir) ] if cuda.is_available(): gpus = cuda.list_devices() if gpus and gpus[0].compute_capability >= (2, 0): cuda_tests.append( loader.discover(join(topdir, 'numba/cuda/tests/cudadrv'), 'test*.py', topdir)) cuda_tests.append( loader.discover(join(topdir, 'numba/cuda/tests/cudapy'), 'test*.py', topdir)) else: print("skipped CUDA tests because GPU CC < 2.0") else: print("skipped CUDA tests") self.test = suite.TestSuite(tests=(base_tests, SerialSuite(cuda_tests)))
def discover_tests(startdir): """Discover test under a directory """ # Avoid importing unittest from numba import unittest_support as unittest loader = unittest.TestLoader() suite = loader.discover(startdir) return suite
def test(): import numba.unittest_support as unittest loader = unittest.TestLoader() startdir = "numba.tests" suite = loader.discover(startdir) runner = unittest.TextTestRunner(descriptions=True, verbosity=2, buffer=True) result = runner.run(suite) return result.wasSuccessful()
def multitest(): """ Run tests in multiple processes. """ import numba.unittest_support as unittest import multiprocessing as mp loader = unittest.TestLoader() startdir = "numba.tests" suites = loader.discover(startdir) pool = mp.Pool(processes=mp.cpu_count()) results = pool.map(_multiruntest, suites) return all(results)
def discover_tests(startdir): import numba.unittest_support as unittest loader = unittest.TestLoader() suite = loader.discover(startdir) return suite