def test_dir(completion_test_dir, thirdparty=False): for f_name in os.listdir(completion_test_dir): files_to_execute = [a for a in test_files.items() if a[0] in f_name] lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, []) if f_name.endswith(".py") and (not test_files or files_to_execute): # for python2.5 certain tests are not being done, because it # only has these features partially. if is_py25 and f_name in ['generators.py', 'types.py']: continue if thirdparty: lib = f_name.replace('_.py', '') try: # there is always an underline at the end. # It looks like: completion/thirdparty/pylab_.py __import__(lib) except ImportError: base.summary.append('Thirdparty-Library %s not found.' % f_name) continue path = os.path.join(completion_test_dir, f_name) f = open(path) num_tests, fails = run_test(f.read(), f_name, lines_to_execute) global test_sum base.test_sum += num_tests s = 'run %s tests with %s fails (%s)' % (num_tests, fails, f_name) base.tests_fail += fails print(s) base.summary.append(s)
def collect_dir_tests(base_dir, test_files): for f_name in os.listdir(base_dir): files_to_execute = [a for a in test_files.items() if a[0] in f_name] lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, []) if f_name.endswith(".py") and (not test_files or files_to_execute): path = os.path.join(base_dir, f_name) with open(path) as f: source = f.read() for case in collect_file_tests(source, path, lines_to_execute): yield case
def _get(self, name, operation, execute=False, *args, **kwargs): key = (name, args, frozenset(kwargs.items())) if key not in self.cache: if execute: objs = (getattr(p.module, name)(*args, **kwargs) for p in self.parsers) else: objs = (getattr(p.module, name) for p in self.parsers) self.cache[key] = reduce(operation, objs) return self.cache[key]
def test_dir(refactoring_test_dir): for f_name in os.listdir(refactoring_test_dir): files_to_execute = [a for a in test_files.items() if a[0] in f_name] lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, []) if f_name.endswith(".py") and (not test_files or files_to_execute): path = os.path.join(refactoring_test_dir, f_name) with open(path) as f: num_tests, fails = run_test(f.read(), f_name, lines_to_execute) base.test_sum += num_tests s = 'run %s tests with %s fails (%s)' % (num_tests, fails, f_name) base.tests_fail += fails print(s) base.summary.append(s)
def collect_dir_tests(base_dir, test_files, check_thirdparty=False): for f_name in os.listdir(base_dir): files_to_execute = [a for a in test_files.items() if a[0] in f_name] lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, []) if f_name.endswith(".py") and (not test_files or files_to_execute): skip = None if check_thirdparty: lib = f_name.replace('_.py', '') try: # there is always an underline at the end. # It looks like: completion/thirdparty/pylab_.py __import__(lib) except ImportError: skip = 'Thirdparty-Library %s not found.' % lib path = os.path.join(base_dir, f_name) source = open(path).read() for case in collect_file_tests(StringIO(source), lines_to_execute): case.path = path case.source = source if skip: case.skip = skip yield case