Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dvc/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dvc.exceptions import DvcException
from dvc.system import System
from dvc.utils import dict_md5
from dvc.utils import fspath
from dvc.utils import fspath_py35
from dvc.utils import walk_files
from dvc.utils.compat import str
Expand Down Expand Up @@ -61,6 +62,9 @@ def __init__(self, path, base_path):


def contains_symlink_up_to(path, base_path):
base_path = fspath(base_path)
path = fspath(path)

if base_path not in path:
raise BasePathNotInCheckedPathException(path, base_path)

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/utils/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ def base_path_is_symlink(path):
):
self.assertFalse(contains_symlink_up_to(target_path, base_path))

def test_path_object_and_str_are_valid_arg_types(self):
base_path = "foo"
target_path = os.path.join(base_path, "bar")
self.assertFalse(contains_symlink_up_to(target_path, base_path))
self.assertFalse(
contains_symlink_up_to(PathInfo(target_path), PathInfo(base_path))
)
Copy link
Contributor

@efiop efiop Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record: Could also add a case for one str and one path_info, but the current one is good enough :)



@pytest.mark.parametrize(
"path1, path2",
Expand Down