def load_tests(source_folder, is_valid_set, ignore_list):
	source_folder = source_folder.resolve()
	utils.assert_existing_directory(source_folder)
	files = utils.get_all_files(source_folder, all="*.toml", recursive=True)
	strip_source_folder_len = len(str(source_folder))
	files = [(f, str(f)[strip_source_folder_len+1:-5].replace('\\', '-').replace('/', '-').strip()) for f in files]
	if ignore_list:
		files_ = []
		for f,n in files:
			ignored = False
			for ignore in ignore_list:
				if isinstance(ignore, str):
					if n == ignore:
						ignored = True
						break
				elif ignore.fullmatch(n) is not None: # regex
					ignored = True
					break
			if not ignored:
				files_.append((f, n))
		files = files_
	tests = []
	for f,n in files:
		try:
			tests.append(TomlTest(f, n, is_valid_set))
		except Exception as e:
			print(rf'Error reading {f}, skipping...', file=sys.stderr)
	return tests
def load_tests(source_folder, is_valid_set, ignore_list):
    source_folder = source_folder.resolve()
    utils.assert_existing_directory(source_folder)
    files = utils.get_all_files(source_folder, all="*.toml")
    if ignore_list:
        files = [f for f in files if f.stem not in ignore_list]
    return [TomlTest(f, is_valid_set) for f in files]
예제 #3
0
def load_tests(source_folder, is_valid_set, ignore_list):
    source_folder = source_folder.resolve()
    utils.assert_existing_directory(source_folder)
    files = utils.get_all_files(source_folder, all="*.toml")
    if ignore_list:
        files_ = []
        for f in files:
            ignored = False
            for ignore in ignore_list:
                if isinstance(ignore, str):
                    if f.stem == ignore:
                        ignored = True
                        break
                elif ignore.fullmatch(f.stem) is not None:  # regex
                    ignored = True
                    break
            if not ignored:
                files_.append(f)
        files = files_
    tests = []
    for f in files:
        try:
            tests.append(TomlTest(f, is_valid_set))
        except Exception as e:
            print(rf'Error reading {f}, skipping...', file=sys.stderr)
    return tests
def main():
	extern_root = Path(utils.entry_script_dir(), '..', 'external').resolve()
	utils.assert_existing_directory(extern_root)
	assert extern_root.exists()
	all_tests = { 'valid': dict(), 'invalid': dict() }
	load_valid_inputs(all_tests, extern_root)
	load_invalid_inputs(all_tests, extern_root)
	for validity, sources in all_tests.items():
		for source, tests in sources.items():
			write_test_file('{}/{}'.format(source, validity), tests )
def main():
    extern_root = Path(utils.entry_script_dir(), '..', 'external').resolve()
    utils.assert_existing_directory(extern_root)
    assert extern_root.exists()
    tests = {'valid': dict(), 'invalid': dict()}
    load_valid_inputs(tests, extern_root)
    load_invalid_inputs(tests, extern_root)
    for test_type, test_groups in tests.items():
        for test_group, test_cases in test_groups.items():
            write_test_file('{}/{}'.format(test_group, test_type), test_cases)