mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
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:
+1
-1
@@ -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":
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user