diff --git a/dvc/fs/dvc.py b/dvc/fs/dvc.py index 1a0b8d674..cbe457139 100644 --- a/dvc/fs/dvc.py +++ b/dvc/fs/dvc.py @@ -44,7 +44,7 @@ class DvcFileSystem(FileSystem): # pylint:disable=abstract-method fs_key = "repo" key = self.path.parts(path) - if key == (".",): + if key == (".",) or key == ("",): key = () return (fs_key, *key) diff --git a/tests/unit/fs/test_dvc.py b/tests/unit/fs/test_dvc.py index a183eb0c1..4dd7a9c0c 100644 --- a/tests/unit/fs/test_dvc.py +++ b/tests/unit/fs/test_dvc.py @@ -10,6 +10,20 @@ from dvc.hash_info import HashInfo from dvc.utils.fs import remove +@pytest.mark.parametrize( + "path, key", + [ + ("", ("repo",)), + (".", ("repo",)), + ("foo", ("repo", "foo")), + (os.path.join("dir", "foo"), ("repo", "dir", "foo")), + ], +) +def test_get_key(tmp_dir, dvc, path, key): + fs = DvcFileSystem(repo=dvc) + assert fs._get_key(path) == key + + def test_exists(tmp_dir, dvc): tmp_dir.gen("foo", "foo") dvc.add("foo")