def run_tests(self, handle_coverage=True): """ runs all tests """ sys.stdout.write("Finding files... ") files = self.find_import_files() if self.verbosity > 3: sys.stdout.write('%s ... done.\n' % (self.files_or_dirs)) else: sys.stdout.write('done.\n') sys.stdout.write("Importing test modules ... ") if handle_coverage: coverage_files, coverage = start_coverage_support(self.configuration) file_and_modules_and_module_name = self.find_modules_from_files(files) sys.stdout.write("done.\n") all_tests = self.find_tests_from_modules(file_and_modules_and_module_name) all_tests = self.filter_tests(all_tests) from _pydev_runfiles import pydev_runfiles_unittest test_suite = pydev_runfiles_unittest.PydevTestSuite(all_tests) from _pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.notifyTestsCollected(test_suite.countTestCases()) start_time = time.time() def run_tests(): executed_in_parallel = False if self.jobs > 1: from _pydev_runfiles import pydev_runfiles_parallel #What may happen is that the number of jobs needed is lower than the number of jobs requested #(e.g.: 2 jobs were requested for running 1 test) -- in which case execute_tests_in_parallel will #return False and won't run any tests. executed_in_parallel = pydev_runfiles_parallel.execute_tests_in_parallel( all_tests, self.jobs, self.split_jobs, self.verbosity, coverage_files, self.configuration.coverage_include) if not executed_in_parallel: #If in coverage, we don't need to pass anything here (coverage is already enabled for this execution). runner = pydev_runfiles_unittest.PydevTextTestRunner(stream=sys.stdout, descriptions=1, verbosity=self.verbosity) sys.stdout.write('\n') runner.run(test_suite) if self.configuration.django: get_django_test_suite_runner()(run_tests).run_tests([]) else: run_tests() if handle_coverage: coverage.stop() coverage.save() total_time = 'Finished in: %.2f secs.' % (time.time() - start_time,) pydev_runfiles_xml_rpc.notifyTestRunFinished(total_time)
def run_tests(self, handle_coverage=True): """ runs all tests """ sys.stdout.write("Finding files... ") files = self.find_import_files() if self.verbosity > 3: sys.stdout.write('%s ... done.\n' % (self.files_or_dirs)) else: sys.stdout.write('done.\n') sys.stdout.write("Importing test modules ... ") if handle_coverage: coverage_files, coverage = start_coverage_support(self.configuration) file_and_modules_and_module_name = self.find_modules_from_files(files) sys.stdout.write("done.\n") all_tests = self.find_tests_from_modules(file_and_modules_and_module_name) all_tests = self.filter_tests(all_tests) from _pydev_runfiles import pydev_runfiles_unittest test_suite = pydev_runfiles_unittest.PydevTestSuite(all_tests) from _pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.notifyTestsCollected(test_suite.countTestCases()) start_time = time.time() def run_tests(): executed_in_parallel = False if self.jobs > 1: from _pydev_runfiles import pydev_runfiles_parallel #What may happen is that the number of jobs needed is lower than the number of jobs requested #(e.g.: 2 jobs were requested for running 1 test) -- in which case execute_tests_in_parallel will #return False and won't run any tests. executed_in_parallel = pydev_runfiles_parallel.execute_tests_in_parallel( all_tests, self.jobs, self.split_jobs, self.verbosity, coverage_files, self.configuration.coverage_include) if not executed_in_parallel: #If in coverage, we don't need to pass anything here (coverage is already enabled for this execution). runner = pydev_runfiles_unittest.PydevTextTestRunner(stream=sys.stdout, descriptions=1, verbosity=self.verbosity) sys.stdout.write('\n') runner.run(test_suite) if self.configuration.django: get_django_test_suite_runner()(run_tests).run_tests([]) else: run_tests() if handle_coverage: coverage.stop() coverage.save() total_time = 'Finished in: %.2f secs.' % (time.time() - start_time,) pydev_runfiles_xml_rpc.notifyTestRunFinished(total_time)
def pytest_collection_modifyitems(session, config, items): # A note: in xdist, this is not called on the main process, only in the # secondary nodes, so, we'll actually make the filter and report it multiple # times. connect_to_server_for_communication_to_xml_rpc_on_xdist() _load_filters() if not py_test_accept_filter: pydev_runfiles_xml_rpc.notifyTestsCollected(len(items)) return # Keep on going (nothing to filter) new_items = [] for item in items: f = _NormFile(str(item.parent.fspath)) name = item.name if f not in py_test_accept_filter: # print('Skip file: %s' % (f,)) continue # Skip the file accept_tests = py_test_accept_filter[f] if item.cls is not None: class_name = item.cls.__name__ else: class_name = None for test in accept_tests: # This happens when parameterizing pytest tests. i = name.find('[') if i > 0: name = name[:i] if test == name: # Direct match of the test (just go on with the default # loading) new_items.append(item) break if class_name is not None: if test == class_name + '.' + name: new_items.append(item) break if class_name == test: new_items.append(item) break else: pass # print('Skip test: %s.%s. Accept: %s' % (class_name, name, accept_tests)) # Modify the original list items[:] = new_items pydev_runfiles_xml_rpc.notifyTestsCollected(len(items))
def pytest_collection_modifyitems(session, config, items): # A note: in xdist, this is not called on the main process, only in the # secondary nodes, so, we'll actually make the filter and report it multiple # times. connect_to_server_for_communication_to_xml_rpc_on_xdist() _load_filters() if not py_test_accept_filter: pydev_runfiles_xml_rpc.notifyTestsCollected(len(items)) return # Keep on going (nothing to filter) new_items = [] for item in items: f = _NormFile(str(item.parent.fspath)) name = item.name if f not in py_test_accept_filter: # print('Skip file: %s' % (f,)) continue # Skip the file accept_tests = py_test_accept_filter[f] if item.cls is not None: class_name = item.cls.__name__ else: class_name = None for test in accept_tests: # This happens when parameterizing pytest tests. i = name.find('[') if i > 0: name = name[:i] if test == name: # Direct match of the test (just go on with the default # loading) new_items.append(item) break if class_name is not None: if test == class_name + '.' + name: new_items.append(item) break if class_name == test: new_items.append(item) break else: pass # print('Skip test: %s.%s. Accept: %s' % (class_name, name, accept_tests)) # Modify the original list items[:] = new_items pydev_runfiles_xml_rpc.notifyTestsCollected(len(items))
def pytest_collection_modifyitems(): connect_to_server_for_communication_to_xml_rpc_on_xdist() pydev_runfiles_xml_rpc.notifyTestsCollected(State.numcollected) State.numcollected = 0
def pytest_collection_modifyitems(): connect_to_server_for_communication_to_xml_rpc_on_xdist() pydev_runfiles_xml_rpc.notifyTestsCollected(State.numcollected) State.numcollected = 0