mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #2740 from algomaster99/test-arg-types-symlink
Ensure `contains_symlink_up_to` accept both str and Path-like objects
This commit is contained in:
@@ -9,6 +9,7 @@ import nanotime
|
||||
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
|
||||
@@ -61,6 +62,9 @@ class BasePathNotInCheckedPathException(DvcException):
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -94,6 +94,14 @@ class TestContainsLink(TestCase):
|
||||
):
|
||||
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))
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path1, path2",
|
||||
|
||||
Reference in New Issue
Block a user