def test_dir_does_not_exist(test_dir_path): random_dir_name = "".join( (chr(random.randint(97, 120)) for _ in range(10))) path = test_dir_path / random_dir_name with pytest.raises(FileNotFoundError, match=f"Path '{path}' does not exists"): universal_file_counter(path, "ext")
def test_recursive_search(test_dir_path): assert universal_file_counter(test_dir_path, "txt", str.split, recursive=True) == 18
def test_several_txt_files_with_tokenizer(test_dir_path): assert universal_file_counter(test_dir_path, "txt", str.split) == 10
def test_several_txt_files_no_tokenizer(test_dir_path): assert universal_file_counter(test_dir_path, "txt") == 6
def test_no_satisfying_files(test_dir_path): assert universal_file_counter(test_dir_path, "none") == 0
def test_single_file_with_tokenizer(test_dir_path): path = test_dir_path / "subdir" / "subsubdir" assert universal_file_counter(path, "txt", str.split) == 5
def test_single_file_no_tokenizer(test_dir_path): path = test_dir_path / "subdir" / "subsubdir" assert universal_file_counter(path, "txt") == 3
def test_empty_directory(empty_directory): assert universal_file_counter(empty_directory, "*") == 0