Merge pull request #2741 from algomaster99/remove-get-parent-dirs

Remove `get_parent_dirs_up_to`
This commit is contained in:
Ruslan Kuprieiev
2019-11-05 23:01:31 +02:00
committed by GitHub
2 changed files with 0 additions and 63 deletions
-19
View File
@@ -75,22 +75,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
-44
View File
@@ -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
@@ -103,49 +102,6 @@ class TestContainsLink(TestCase):
)
@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")