diff --git a/doit/dependency.py b/doit/dependency.py index 84973144..85092ac8 100644 --- a/doit/dependency.py +++ b/doit/dependency.py @@ -36,6 +36,9 @@ def get_file_md5(path): @param path: (string) file path @return: (string) md5 """ + if os.path.isdir(path): + raise ValueError("Cannot compute MD5 sum of directory. You must " + "specify a file as a dependency instead.") with open(path, 'rb') as file_data: md5 = hashlib.md5() block_size = 128 * md5.block_size diff --git a/tests/test_dependency.py b/tests/test_dependency.py index 38d71f42..93c6457c 100644 --- a/tests/test_dependency.py +++ b/tests/test_dependency.py @@ -34,6 +34,9 @@ def test_md5(): expected_crlf = "cf7b48b2fec3b581b135f7c9a1f7ae04" assert get_file_md5(filePath) in {expected_lf, expected_crlf} + with pytest.raises(ValueError): + get_file_md5(os.path.dirname(filePath)) + def test_sqlite_import(): """