コード例 #1
0
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")
コード例 #2
0
def test_recursive_search(test_dir_path):
    assert universal_file_counter(test_dir_path,
                                  "txt",
                                  str.split,
                                  recursive=True) == 18
コード例 #3
0
def test_several_txt_files_with_tokenizer(test_dir_path):
    assert universal_file_counter(test_dir_path, "txt", str.split) == 10
コード例 #4
0
def test_several_txt_files_no_tokenizer(test_dir_path):
    assert universal_file_counter(test_dir_path, "txt") == 6
コード例 #5
0
def test_no_satisfying_files(test_dir_path):
    assert universal_file_counter(test_dir_path, "none") == 0
コード例 #6
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
コード例 #7
0
def test_single_file_no_tokenizer(test_dir_path):
    path = test_dir_path / "subdir" / "subsubdir"
    assert universal_file_counter(path, "txt") == 3
コード例 #8
0
def test_empty_directory(empty_directory):
    assert universal_file_counter(empty_directory, "*") == 0