def test(folder=None, remove=True, predicate=None): """Runs all pypet tests :param folder: Temporary folder to put data in, leave `None` for automatic choice. :param remove: If temporary data should be removed after the tests. :param predicate: Predicate to specify subset of tests. Must take three arguments ``class_name``, ``test_name``, ``tags`` and evaluate to `True` if a test should be run. Leave `None` for all tests. """ if predicate is None: predicate = lambda class_name, test_name, tags: class_name != TEST_IMPORT_ERROR suite = discover_tests(predicate=predicate) run_suite(suite=suite, remove=remove, folder=folder)
exclude_set = set(('hdf5_settings', 'multiproc', 'merge')) integration_pred = lambda class_name, test_name, tags: ( 'integration' in tags and not bool(exclude_set & tags)) integration_suite = discover_tests(integration_pred) include_set = set(('hdf5_settings', 'links', 'merge')) integration_pred_2 = lambda class_name, test_name, tags: ( 'integration' in tags and bool(include_set & tags) and 'multiproc' not in tags and 'links' not in tags) integration_suite_2 = discover_tests(integration_pred_2) suite_dict = { '1': unit_suite, '2': integration_suite, '3': integration_suite_2 } if __name__ == '__main__': opt_dict = parse_args() suite = None if 'suite_no' in opt_dict: suite_no = opt_dict.pop('suite_no') suite = suite_dict[suite_no] if suite is None: pred = lambda class_name, test_name, tags: ( 'multiproc' not in tags and class_name != TEST_IMPORT_ERROR) suite = discover_tests(pred) run_suite(suite=suite, **opt_dict)
__author__ = 'robert' try: import pypet except ImportError: import sys sys.path.append('/media/data/PYTHON_WORKSPACE/pypet-project') import scoop from pypet.tests.testutils.ioutils import discover_tests, parse_args, run_suite from pypet.tests.integration.environment_scoop_test import check_mock scoop_suite = discover_tests(lambda class_name, test_name, tags: 'scoop' in tags) if __name__ == '__main__': mock = check_mock() if mock: raise RuntimeError('Not running in SCOOP mode!') opt_dict = parse_args() run_suite(suite=scoop_suite, **opt_dict)
self.create_file(filename) self.start_server(url) lock = LockerClient(url) lock.start() iterator = [(irun, lock, filename) for irun in range(self.ITERATIONS)] list(futures.map(the_job, iterator)) lock.send_done() self.check_file(filename) self.lock_process.join() # errwrite(str(irun)) self.ITERATIONS = old_iter def test_timout_pool(self): pool = mp.Pool(5) url = get_random_port_url() self.start_timeout_server(url, 0.25) lock = LockerClient(url) lock.start() iterator = [(irun, lock) for irun in range(self.ITERATIONS)] potential_timeouts = list(pool.imap(time_out_job, iterator)) pool.close() pool.join() all_time_outs = [x for x in potential_timeouts if x] self.assertGreaterEqual(len(all_time_outs), 1) lock.send_done() self.lock_process.join() if __name__ == '__main__': opt_args = parse_args() run_suite(**opt_args)
node.v_annotations.f_get() with self.assertRaises(AttributeError): node.v_annotations.f_get('gdsdfd') testparam = self.traj.f_add_parameter('ggg', 343) with self.assertRaises(AttributeError): testparam.v_annotations.f_get() def test_f_set_numbering(self): int_list = list(range(10)) for node in self.traj.f_iter_nodes(recursive=True): node.v_annotations.f_set(*int_list) self.assertEqual(node.v_annotations.f_get(*int_list), tuple(int_list)) for integer in int_list: if integer == 0: name = 'annotation' else: name = 'annotation_%d' % integer self.assertTrue(name in node.v_annotations) if __name__ == '__main__': opt_args = parse_args() run_suite(**opt_args)
return Process_WithCoverage ProcessCoverage = coverage_multiprocessing_process() if ProcessCoverage: multiprocessing.Process = ProcessCoverage print('Added Monkey-Patch for multiprocessing and code-coverage') import sys import os pypetpath=os.path.abspath(os.getcwd()) sys.path.append(pypetpath) print('Appended path `%s`' % pypetpath) from pypet.tests.testutils.ioutils import run_suite, discover_tests, TEST_IMPORT_ERROR, parse_args if __name__ == '__main__': opt_dict = parse_args() tests_include = set(('TestMPImmediatePostProc', 'MultiprocFrozenPoolSortQueueTest', 'MultiprocLinkNoPoolLockTest', 'MultiprocLinkNoPoolQueueTest', 'MultiprocLinkQueueTest', 'CapTest')) pred = lambda class_name, test_name, tags: (class_name in tests_include or 'multiproc' not in tags) suite = discover_tests(pred) run_suite(suite=suite, **opt_dict)
__author__ = 'Robert Meyer' from pypet.tests.testutils.ioutils import run_suite, discover_tests, TEST_IMPORT_ERROR if __name__ == '__main__': suite = discover_tests(predicate=lambda class_name, test_name, tags: class_name != TEST_IMPORT_ERROR) run_suite(remove=False, folder=None, suite=suite)
__author__ = 'Robert Meyer' from pypet.tests.testutils.ioutils import run_suite, discover_tests, TEST_IMPORT_ERROR if __name__ == '__main__': suite = discover_tests(predicate= lambda class_name, test_name, tags: class_name != TEST_IMPORT_ERROR) run_suite(remove=False, folder=None, suite=suite)