Merge pull request #2746 from algomaster99/test-arg-types-file_md5

Ensure `file_md5` accept str and Path-like objects
This commit is contained in:
Ruslan Kuprieiev
2019-11-06 14:01:20 +02:00
committed by GitHub
3 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ class RemoteLOCAL(RemoteBASE):
yield PathInfo(fname)
def get_file_checksum(self, path_info):
return file_md5(fspath_py35(path_info))[0]
return file_md5(path_info)[0]
def remove(self, path_info):
if path_info.scheme != "local":
+2
View File
@@ -44,6 +44,8 @@ def file_md5(fname):
from dvc.progress import Tqdm
from dvc.istextfile import istextfile
fname = fspath_py35(fname)
if os.path.exists(fname):
hash_md5 = hashlib.md5()
binary = not istextfile(fname)
+8
View File
@@ -2,6 +2,8 @@ import os
import pytest
from dvc.path_info import PathInfo
from dvc.utils import file_md5
from dvc.utils import fix_env
from dvc.utils import to_chunks
@@ -71,3 +73,9 @@ def test_fix_env_pyenv(path, orig):
"PYENV_HOOK_PATH": "/some/hook/path",
}
assert fix_env(env)["PATH"] == orig
def test_file_md5(repo_dir):
fname = repo_dir.FOO
fname_object = PathInfo(fname)
assert file_md5(fname) == file_md5(fname_object)