diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index 7b2e349c8..cfe0febfc 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -35,6 +35,7 @@ from tests.remotes import ( GCP, GDrive, HDFS, + Local, S3, SSHMocked, OSS, @@ -44,7 +45,6 @@ from tests.remotes import ( TEST_GDRIVE_CLIENT_ID, TEST_GDRIVE_CLIENT_SECRET, TEST_REMOTE, - get_local_url, ) @@ -278,10 +278,10 @@ class TestRemoteOSS(TestDataCloudBase): class TestRemoteLOCAL(TestDataCloudBase): def _should_test(self): - return True + return Local.should_test() def _get_url(self): - self.dname = get_local_url() + self.dname = Local.get_url() return self.dname def _get_cloud_class(self): @@ -420,7 +420,7 @@ class TestDataCloudCLIBase(TestDvc): class TestRemoteLOCALCLI(TestDataCloudCLIBase): def _test(self): - url = get_local_url() + url = Local.get_url() self.main(["remote", "add", TEST_REMOTE, url]) @@ -545,7 +545,7 @@ class TestWarnOnOutdatedStage(TestDvc): self.assertEqual(ret, 0) def _test(self): - url = get_local_url() + url = Local.get_url() self.main(["remote", "add", "-d", TEST_REMOTE, url]) stage = self.dvc.run(outs=["bar"], cmd="echo bar > bar") @@ -577,11 +577,11 @@ class TestRecursiveSyncOperations(TestDataCloudBase): self.assertEqual(ret, 0) def _get_url(self): - self.dname = get_local_url() + self.dname = Local.get_url() return self.dname def _should_test(self): - return True + return Local.should_test() def _get_cloud_class(self): return RemoteLOCAL @@ -659,7 +659,7 @@ class TestCheckSumRecalculation(TestDvc): with patch.object( RemoteLOCAL, "get_file_checksum", test_get_file_checksum ): - url = get_local_url() + url = Local.get_url() ret = main(["remote", "add", "-d", TEST_REMOTE, url]) self.assertEqual(ret, 0) ret = main(["config", "cache.type", "hardlink"]) diff --git a/tests/func/test_remote.py b/tests/func/test_remote.py index 09674eff3..c6d1cffe9 100644 --- a/tests/func/test_remote.py +++ b/tests/func/test_remote.py @@ -14,7 +14,7 @@ from dvc.remote import RemoteLOCAL, RemoteConfig from dvc.remote.base import RemoteBASE from dvc.compat import fspath from tests.basic_env import TestDvc -from tests.remotes import get_local_storagepath +from tests.remotes import Local class TestRemote(TestDvc): @@ -159,7 +159,7 @@ class TestRemoteShouldHandleUppercaseRemoteName(TestDvc): upper_case_remote_name = "UPPERCASEREMOTE" def test(self): - remote_url = get_local_storagepath() + remote_url = Local.get_storagepath() ret = main(["remote", "add", self.upper_case_remote_name, remote_url]) self.assertEqual(ret, 0) diff --git a/tests/remotes.py b/tests/remotes.py index 4623c7606..cf80fd160 100644 --- a/tests/remotes.py +++ b/tests/remotes.py @@ -43,17 +43,16 @@ TEST_GDRIVE_CLIENT_ID = ( TEST_GDRIVE_CLIENT_SECRET = "2fy_HyzSwkxkGzEken7hThXb" -def get_local_storagepath(): - return TestDvc.mkdtemp() - - -def get_local_url(): - return get_local_storagepath() - - class Local: should_test = lambda: True # noqa: E731 - get_url = get_local_url + + @staticmethod + def get_storagepath(): + return TestDvc.mkdtemp() + + @staticmethod + def get_url(): + return Local.get_storagepath() class S3: @@ -215,7 +214,7 @@ class SSH: @staticmethod def get_url(): return "ssh://{}@127.0.0.1:22{}".format( - getpass.getuser(), get_local_storagepath() + getpass.getuser(), Local.get_storagepath() ) @@ -224,9 +223,9 @@ class SSHMocked: @staticmethod def get_url(user, port): - path = get_local_storagepath() + path = Local.get_storagepath() if os.name == "nt": - # NOTE: On Windows get_local_storagepath() will return an + # NOTE: On Windows Local.get_storagepath() will return an # ntpath that looks something like `C:\some\path`, which is not # compatible with SFTP paths [1], so we need to convert it to # a proper posixpath. @@ -273,5 +272,5 @@ class HDFS: @staticmethod def get_url(): return "hdfs://{}@127.0.0.1{}".format( - getpass.getuser(), get_local_storagepath() + getpass.getuser(), Local.get_storagepath() )