From 8491ddf43f753ab51dee3ddd416757ed224a3649 Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Wed, 6 Nov 2019 02:03:47 +0530 Subject: [PATCH] Remove `get_parent_dirs_up_to` --- dvc/utils/fs.py | 19 ---------------- tests/unit/utils/test_fs.py | 44 ------------------------------------- 2 files changed, 63 deletions(-) diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py index 572423544..4761ade58 100644 --- a/dvc/utils/fs.py +++ b/dvc/utils/fs.py @@ -71,22 +71,3 @@ def contains_symlink_up_to(path, base_path): if os.path.dirname(path) == path: return False return contains_symlink_up_to(os.path.dirname(path), base_path) - - -def get_parent_dirs_up_to(wdir, root_dir): - - assert os.path.isabs(wdir) - assert os.path.isabs(root_dir) - - wdir = os.path.normpath(wdir) - root_dir = os.path.normpath(root_dir) - if root_dir not in wdir: - return [] - - dirs = [] - dirs.append(wdir) - while wdir != root_dir: - wdir = os.path.dirname(wdir) - dirs.append(wdir) - - return dirs diff --git a/tests/unit/utils/test_fs.py b/tests/unit/utils/test_fs.py index 322e90c16..44a253396 100644 --- a/tests/unit/utils/test_fs.py +++ b/tests/unit/utils/test_fs.py @@ -14,7 +14,6 @@ from dvc.utils.fs import BasePathNotInCheckedPathException from dvc.utils.fs import contains_symlink_up_to from dvc.utils.fs import get_inode from dvc.utils.fs import get_mtime_and_size -from dvc.utils.fs import get_parent_dirs_up_to from tests.basic_env import TestDir from tests.utils import spy @@ -95,49 +94,6 @@ class TestContainsLink(TestCase): self.assertFalse(contains_symlink_up_to(target_path, base_path)) -@pytest.mark.parametrize( - "path1, path2", - [ - ( - os.path.join("non", "abs", "path"), - os.path.join(os.sep, "full", "path"), - ), - ( - os.path.join(os.sep, "full", "path"), - os.path.join("non", "abs", "path"), - ), - ], -) -def test_get_parent_dirs_up_to_should_raise_on_no_absolute(path1, path2): - with pytest.raises(AssertionError): - get_parent_dirs_up_to(path1, path2) - - -@pytest.mark.parametrize( - "path1, path2, expected_dirs", - [ - ( - os.path.join(os.sep, "non", "matching", "path"), - os.path.join(os.sep, "other", "path"), - [], - ), - ( - os.path.join(os.sep, "some", "long", "path"), - os.path.join(os.sep, "some"), - [ - os.path.join(os.sep, "some"), - os.path.join(os.sep, "some", "long"), - os.path.join(os.sep, "some", "long", "path"), - ], - ), - ], -) -def test_get_parent_dirs_up_to(path1, path2, expected_dirs): - result = get_parent_dirs_up_to(path1, path2) - - assert set(result) == set(expected_dirs) - - @pytest.mark.skipif(os.name != "nt", reason="Windows specific") def test_relpath_windows_different_drives(): path1 = os.path.join("A:", os.sep, "some", "path")