Skip to content

test: refactor & remove redundant test fixtures #2861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/func/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def test_get_url(repo_dir, dvc_repo, remote_url):


@pytest.mark.parametrize("remote_url", remote_params, indirect=True)
def test_get_url_external(repo_dir, dvc_repo, erepo, remote_url):
def test_get_url_external(dvc_repo, erepo, remote_url):
_set_remote_url_and_commit(erepo.dvc, remote_url)

# Using file url to force clone to tmp repo
repo_url = "file://" + erepo.dvc.root_dir
expected_url = URLInfo(remote_url) / "ac/bd18db4cc2f85cedef654fccc4a4d8"
assert api.get_url(repo_dir.FOO, repo=repo_url) == expected_url
assert api.get_url(erepo.FOO, repo=repo_url) == expected_url


@pytest.mark.parametrize("remote_url", all_remote_params, indirect=True)
Expand All @@ -107,7 +107,7 @@ def test_open(repo_dir, dvc_repo, remote_url):


@pytest.mark.parametrize("remote_url", all_remote_params, indirect=True)
def test_open_external(repo_dir, dvc_repo, erepo, remote_url):
def test_open_external(dvc_repo, erepo, remote_url):
erepo.dvc.scm.checkout("branch")
_set_remote_url_and_commit(erepo.dvc, remote_url)
erepo.dvc.scm.checkout("master")
Expand Down
16 changes: 8 additions & 8 deletions tests/func/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
from tests.utils import trees_equal


def test_get_repo_file(repo_dir, erepo):
def test_get_repo_file(erepo):
src = erepo.FOO
dst = erepo.FOO + "_imported"

Repo.get(erepo.root_dir, src, dst)

assert os.path.exists(dst)
assert os.path.isfile(dst)
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
assert filecmp.cmp(erepo.FOO, dst, shallow=False)


def test_get_repo_dir(repo_dir, erepo):
def test_get_repo_dir(erepo):
src = erepo.DATA_DIR
dst = erepo.DATA_DIR + "_imported"

Expand All @@ -36,7 +36,7 @@ def test_get_repo_dir(repo_dir, erepo):
trees_equal(src, dst)


def test_cache_type_is_properly_overridden(repo_dir, erepo):
def test_cache_type_is_properly_overridden(erepo):
erepo.dvc.config.set(
Config.SECTION_CACHE, Config.SECTION_CACHE_TYPE, "symlink"
)
Expand All @@ -53,7 +53,7 @@ def test_cache_type_is_properly_overridden(repo_dir, erepo):
assert os.path.isfile(dst)


def test_get_repo_rev(repo_dir, erepo):
def test_get_repo_rev(erepo):
src = "version"
dst = src

Expand All @@ -70,13 +70,13 @@ def test_get_from_non_dvc_repo(git_erepo):
Repo.get(git_erepo.root_dir, "some_file.zip")


def test_get_a_dvc_file(repo_dir, erepo):
def test_get_a_dvc_file(erepo):
with pytest.raises(GetDVCFileError):
Repo.get(erepo.root_dir, "some_file.dvc")


@pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"])
def test_get_to_dir(dname, repo_dir, erepo):
def test_get_to_dir(dname, erepo):
src = erepo.FOO

makedirs(dname, exist_ok=True)
Expand All @@ -86,4 +86,4 @@ def test_get_to_dir(dname, repo_dir, erepo):
dst = os.path.join(dname, os.path.basename(src))

assert os.path.isdir(dname)
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
assert filecmp.cmp(erepo.FOO, dst, shallow=False)
16 changes: 8 additions & 8 deletions tests/func/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
from tests.utils import trees_equal


def test_import(repo_dir, git, dvc_repo, erepo):
def test_import(git, dvc_repo, erepo):
src = erepo.FOO
dst = erepo.FOO + "_imported"

dvc_repo.imp(erepo.root_dir, src, dst)

assert os.path.exists(dst)
assert os.path.isfile(dst)
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
assert filecmp.cmp(erepo.FOO, dst, shallow=False)
assert git.git.check_ignore(dst)


def test_import_dir(repo_dir, git, dvc_repo, erepo):
def test_import_dir(git, dvc_repo, erepo):
src = erepo.DATA_DIR
dst = erepo.DATA_DIR + "_imported"

Expand All @@ -39,7 +39,7 @@ def test_import_dir(repo_dir, git, dvc_repo, erepo):
assert git.git.check_ignore(dst)


def test_import_rev(repo_dir, git, dvc_repo, erepo):
def test_import_rev(git, dvc_repo, erepo):
src = "version"
dst = src

Expand Down Expand Up @@ -70,7 +70,7 @@ def test_pull_imported_stage(dvc_repo, erepo):
assert os.path.isfile(dst_cache)


def test_cache_type_is_properly_overridden(repo_dir, git, dvc_repo, erepo):
def test_cache_type_is_properly_overridden(git, dvc_repo, erepo):
erepo.dvc.config.set(
Config.SECTION_CACHE, Config.SECTION_CACHE_TYPE, "symlink"
)
Expand All @@ -85,7 +85,7 @@ def test_cache_type_is_properly_overridden(repo_dir, git, dvc_repo, erepo):
assert not System.is_symlink(dst)
assert os.path.exists(dst)
assert os.path.isfile(dst)
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
assert filecmp.cmp(erepo.FOO, dst, shallow=False)
assert git.git.check_ignore(dst)


Expand Down Expand Up @@ -125,7 +125,7 @@ def test_download_error_pulling_imported_stage(dvc_repo, erepo):


@pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"])
def test_import_to_dir(dname, repo_dir, dvc_repo, erepo):
def test_import_to_dir(dname, dvc_repo, erepo):
src = erepo.FOO

makedirs(dname, exist_ok=True)
Expand All @@ -136,7 +136,7 @@ def test_import_to_dir(dname, repo_dir, dvc_repo, erepo):

assert stage.outs[0].fspath == os.path.abspath(dst)
assert os.path.isdir(dname)
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
assert filecmp.cmp(erepo.FOO, dst, shallow=False)


def test_pull_non_workspace(git, dvc_repo, erepo):
Expand Down