diff --git a/tests/func/test_dependency.py b/tests/func/test_dependency.py index e1e1385a0..c0f9279fd 100644 --- a/tests/func/test_dependency.py +++ b/tests/func/test_dependency.py @@ -1,15 +1,21 @@ +import copy +import pytest + from dvc.stage import Stage from dvc.dependency import _get, DEP_MAP -from tests.func.test_output import TestOutScheme +from tests.func.test_output import TESTS as OUT_TESTS -class TestDepScheme(TestOutScheme): - MAP = DEP_MAP +TESTS = copy.copy(OUT_TESTS) +TESTS.append(("http://example.com/path/to/file", "http")) +TESTS.append(("https://example.com/path/to/file", "https")) - TESTS = TestOutScheme.TESTS.copy() - TESTS["http://example.com/path/to/file"] = "http" - TESTS["https://example.com/path/to/file"] = "https" - def _get(self, path): - return _get(Stage(self.dvc), path, None) +def _get_dep(dvc, path): + return _get(Stage(dvc), path, None) + + +@pytest.mark.parametrize("url,scheme", TESTS) +def test_scheme(dvc, url, scheme): + assert type(_get_dep(dvc, url)) == DEP_MAP[scheme] diff --git a/tests/func/test_output.py b/tests/func/test_output.py index cf96dd031..300b263f2 100644 --- a/tests/func/test_output.py +++ b/tests/func/test_output.py @@ -1,30 +1,29 @@ +import pytest + from dvc.stage import Stage from dvc.output import _get, OUTS_MAP -from tests.basic_env import TestDvc + +TESTS = [ + ("s3://bucket/path", "s3"), + ("gs://bucket/path", "gs"), + ("ssh://example.com:/dir/path", "ssh"), + ("hdfs://example.com/dir/path", "hdfs"), + ("path/to/file", "local"), + ("path\\to\\file", "local"), + ("file", "local"), + ("./file", "local"), + (".\\file", "local"), + ("../file", "local"), + ("..\\file", "local"), + ("unknown://path", "local"), +] -class TestOutScheme(TestDvc): - MAP = OUTS_MAP +def _get_out(dvc, path): + return _get(Stage(dvc), path, None, None, None, None) - TESTS = { - "s3://bucket/path": "s3", - "gs://bucket/path": "gs", - "ssh://example.com:/dir/path": "ssh", - "hdfs://example.com/dir/path": "hdfs", - "path/to/file": "local", - "path\\to\\file": "local", - "file": "local", - "./file": "local", - ".\\file": "local", - "../file": "local", - "..\\file": "local", - "unknown://path": "local", - } - def _get(self, path): - return _get(Stage(self.dvc), path, None, None, None, None) - - def test(self): - for path, cls in self.TESTS.items(): - self.assertIsInstance(self._get(path), self.MAP[cls]) +@pytest.mark.parametrize("url,scheme", TESTS) +def test_scheme(dvc, url, scheme): + assert type(_get_out(dvc, url)) == OUTS_MAP[scheme]