diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py index eaf776a2e..c5a1e55c6 100644 --- a/dvc/dependency/repo.py +++ b/dvc/dependency/repo.py @@ -35,7 +35,7 @@ class RepoDependency(Dependency): super().__init__(stage, *args, **kwargs) self.fs = self._make_fs() - self.fs_path = as_posix(self.def_path) + self.fs_path = as_posix(self.fs.normpath(self.def_path)) def _parse_path(self, fs, fs_path): # noqa: ARG002 return None diff --git a/tests/func/test_import.py b/tests/func/test_import.py index 873ad8dd7..125337811 100644 --- a/tests/func/test_import.py +++ b/tests/func/test_import.py @@ -305,11 +305,12 @@ def test_cache_type_is_properly_overridden(tmp_dir, scm, dvc, erepo_dir): assert scm.is_ignored("foo_imported") -def test_pull_imported_directory_stage(tmp_dir, dvc, erepo_dir): +@pytest.mark.parametrize("dirpath", ["dir", "dir/"]) +def test_pull_imported_directory_stage(tmp_dir, dvc, erepo_dir, dirpath): with erepo_dir.chdir(): erepo_dir.dvc_gen({"dir": {"foo": "foo content"}}, commit="create dir") - dvc.imp(os.fspath(erepo_dir), "dir", "dir_imported") + stage = dvc.imp(os.fspath(erepo_dir), dirpath, "dir_imported") remove("dir_imported") dvc.cache.local.clear() @@ -317,6 +318,7 @@ def test_pull_imported_directory_stage(tmp_dir, dvc, erepo_dir): dvc.pull(["dir_imported.dvc"]) assert (tmp_dir / "dir_imported").read_text() == {"foo": "foo content"} + assert stage.deps[0].fs_path == "dir" def test_pull_wildcard_imported_directory_stage(tmp_dir, dvc, erepo_dir):