diff --git a/tests/func/test_api.py b/tests/func/test_api.py index 4218e9eec..695861358 100644 --- a/tests/func/test_api.py +++ b/tests/func/test_api.py @@ -1,11 +1,10 @@ import os -import platform import pytest from funcy import first, get_in from dvc import api -from dvc.exceptions import DvcException, FileMissingError, OutputNotFoundError +from dvc.exceptions import FileMissingError, OutputNotFoundError from dvc.path_info import URLInfo from dvc.utils.fs import remove from tests.unit.tree.test_repo import make_subrepo @@ -26,7 +25,7 @@ def test_get_url(tmp_dir, dvc, remote): @pytest.mark.parametrize("cloud", clouds) -def test_get_url_external(erepo_dir, cloud): +def test_get_url_external(tmp_dir, erepo_dir, cloud): erepo_dir.add_remote(config=cloud.config) with erepo_dir.chdir(): erepo_dir.dvc_gen("foo", "foo", commit="add foo") @@ -62,29 +61,20 @@ def test_open(tmp_dir, dvc, remote): @pytest.mark.parametrize( "cloud", [ - *[ - pytest.lazy_fixture(cloud) - for cloud in [ - "real_s3", # NOTE: moto's s3 fails in some tests - "gs", - "azure", - "gdrive", - "oss", - "http", - "hdfs", - ] - ], - pytest.param( - pytest.lazy_fixture("ssh"), - marks=pytest.mark.xfail( - raises=DvcException, - condition=platform.system() == "Windows", - reason="https://github.com/iterative/dvc/issues/4418", - ), - ), + pytest.lazy_fixture(cloud) + for cloud in [ + "real_s3", # NOTE: moto's s3 fails in some tests + "gs", + "azure", + "gdrive", + "oss", + "http", + "hdfs", + "ssh", + ] ], ) -def test_open_external(erepo_dir, cloud): +def test_open_external(tmp_dir, erepo_dir, cloud): erepo_dir.add_remote(config=cloud.config) with erepo_dir.chdir(): diff --git a/tests/remotes/ssh.py b/tests/remotes/ssh.py index 7705b17e0..68cf73726 100644 --- a/tests/remotes/ssh.py +++ b/tests/remotes/ssh.py @@ -27,13 +27,19 @@ class SSHMocked(Base, URLInfo): # a proper posixpath. # To do that, we should construct a posixpath that would be # relative to the server's root. - # In our case our ssh server is running with `c:/` as a root, - # and our URL format requires absolute paths, so the + # Our URL format requires absolute paths, so the # resulting path would look like `/some/path`. # # [1]https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-6 drive, path = os.path.splitdrive(path) - assert drive.lower() == "c:" + + # Hackish way to make sure SSH server runs on same drive as tests + # and temporary directories are. + # Context: https://github.com/iterative/dvc/pull/4660 + test_drive, _ = os.path.splitdrive(os.getcwd()) + if drive.lower() != test_drive.lower(): + raise Exception("Did you forget to use `tmp_dir?`") + path = path.replace("\\", "/") url = f"ssh://{user}@127.0.0.1:{port}{path}" return url