def test_find_wrong_command(path): with pytest.raises(search.SearchError): search.grep_dir( search.find_dir(path, ["txt"], ["python"], find_cmd="no_such_find_cmdn"))
def test_find_wrong_path(path): with pytest.raises(search.SearchError): search.grep_dir( search.find_dir(os.path.join(path, "nosuchdir"), ["txt"], ["python"]))
def test_find_one_file(path): matches = search.find_dir(path, ["txt"], ["python"]) assert len(matches) == 1 assert matches[0] == "python cheatsheet.txt"
def test_find_right_extension(path): matches = search.find_dir(path, ["gif"], ["che", "py"]) assert len(matches) == 0
def test_find_pattern_with_two_parts_swapped(path): matches = search.find_dir(path, ["txt"], ["che", "py"]) assert len(matches) == 1 assert matches[0] == "python cheatsheet.txt"
def test_find_case_insensitive(path): matches = search.find_dir(path, ["txt"], ["py"]) assert len(matches) == 1 assert matches[0] == "PYTHON cheatsheet.txt"
def test_find_two_files(path): matches = search.find_dir(path, ["txt"], ["cheats"]) assert len(matches) == 2