def test_FileList_singleFile_entry(filelist): basepath = filelist path_entry = _FileList(basepath / "root_file.txt") assert path_entry.entrypoint == basepath / "root_file.txt" assert path_entry.recursive == True assert path_entry.search_pattern == "*" assert path_entry.is_single_file == True assert all(p == (basepath / "root_file.txt") for p in path_entry.paths) assert path_entry.parent_directory == basepath
def test_FileList_wildCards_nonrecursive(filelist): basepath = filelist wildcard_file = _FileList(basepath / "first" / "second" / "*.txt", recursive=False) expected_files = [f"second_{i:02d}.txt" for i in range(10)] assert wildcard_file.entrypoint == basepath / "first" / "second" assert wildcard_file.parent_directory == basepath / "first" / "second" assert wildcard_file.recursive == False for fp in wildcard_file.paths: assert fp.name in expected_files expected_files.remove(fp.name) assert len(expected_files) == 0
def test_FileList_wildCards_recursive(filelist): basepath = filelist wildcard_file = _FileList(basepath / "second_*") expected_files = [f"second_{i:02d}.txt" for i in range(10)] assert wildcard_file.entrypoint == basepath assert wildcard_file.parent_directory == basepath assert wildcard_file.recursive == True assert wildcard_file.search_pattern == "second_*" for fp in wildcard_file.paths: assert fp.name in expected_files expected_files.remove(fp.name) assert len(expected_files) == 0
def test_FileList_nonExisting(): with pytest.raises(ValueError, match="Passed a non-existing path!"): _FileList("some/non/existing/path")