From 204cfcb879d2a722969a3228d9739f325d7edf8d Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Fri, 8 Nov 2019 20:37:32 +0530 Subject: [PATCH] Ensure `makedirs` accepts str and Path-like objects --- dvc/remote/local.py | 2 +- tests/unit/utils/test_utils.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dvc/remote/local.py b/dvc/remote/local.py index 0cffce3d0e..b8ec17529b 100644 --- a/dvc/remote/local.py +++ b/dvc/remote/local.py @@ -224,7 +224,7 @@ def cache_exists(self, checksums, jobs=None, name=None): def _upload( self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs ): - makedirs(fspath_py35(to_info.parent), exist_ok=True) + makedirs(to_info.parent, exist_ok=True) tmp_file = tmp_fname(to_info) copyfile( diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 02c256afd9..6d4aba0bc0 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -7,6 +7,7 @@ from dvc.utils import copyfile from dvc.utils import file_md5 from dvc.utils import fix_env +from dvc.utils import makedirs from dvc.utils import to_chunks from tests.basic_env import TestDir @@ -108,3 +109,16 @@ def test_copyfile(path, repo_dir): ) else: assert filecmp.cmp(src_info.fspath, dest_info.fspath, shallow=False) + + +def test_makedirs(repo_dir): + path = os.path.join(repo_dir.root_dir, "directory") + path_info = PathInfo( + os.path.join(repo_dir.root_dir, "another", "directory") + ) + + makedirs(path) + assert os.path.isdir(path) + + makedirs(path_info) + assert os.path.isdir(path_info.fspath)