Skip to content

Commit

Permalink
tests: use pytest-lazyfixture (#4089)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Jun 23, 2020
1 parent 4181c0e commit 7d45a55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
7 changes: 4 additions & 3 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ def test_verify_hashes(


@flaky(max_runs=3, min_passes=1)
@pytest.mark.parametrize("erepo", ["git_dir", "erepo_dir"])
def test_pull_git_imports(request, tmp_dir, dvc, scm, erepo):
erepo = request.getfixturevalue(erepo)
@pytest.mark.parametrize(
"erepo", [pytest.lazy_fixture("git_dir"), pytest.lazy_fixture("erepo_dir")]
)
def test_pull_git_imports(tmp_dir, dvc, scm, erepo):
with erepo.chdir():
erepo.scm_gen({"dir": {"bar": "bar"}}, commit="second")
erepo.scm_gen("foo", "foo", commit="first")
Expand Down
24 changes: 13 additions & 11 deletions tests/func/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,34 @@ def test_get_repo_dir(tmp_dir, erepo_dir):
trees_equal(erepo_dir / "dir", "dir_imported")


@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
def test_get_git_file(request, tmp_dir, repo_type):
erepo_dir = request.getfixturevalue(repo_type)
@pytest.mark.parametrize(
"erepo", [pytest.lazy_fixture("git_dir"), pytest.lazy_fixture("erepo_dir")]
)
def test_get_git_file(tmp_dir, erepo):
src = "some_file"
dst = "some_file_imported"

erepo_dir.scm_gen({src: "hello"}, commit="add a regular file")
erepo.scm_gen({src: "hello"}, commit="add a regular file")

Repo.get(os.fspath(erepo_dir), src, dst)
Repo.get(os.fspath(erepo), src, dst)

assert (tmp_dir / dst).is_file()
assert (tmp_dir / dst).read_text() == "hello"


@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
def test_get_git_dir(request, tmp_dir, repo_type):
erepo_dir = request.getfixturevalue(repo_type)
@pytest.mark.parametrize(
"erepo", [pytest.lazy_fixture("git_dir"), pytest.lazy_fixture("erepo_dir")]
)
def test_get_git_dir(tmp_dir, erepo):
src = "some_directory"
dst = "some_directory_imported"

erepo_dir.scm_gen({src: {"file.txt": "hello"}}, commit="add a regular dir")
erepo.scm_gen({src: {"file.txt": "hello"}}, commit="add a regular dir")

Repo.get(os.fspath(erepo_dir), src, dst)
Repo.get(os.fspath(erepo), src, dst)

assert (tmp_dir / dst).is_dir()
trees_equal(erepo_dir / src, tmp_dir / dst)
trees_equal(erepo / src, tmp_dir / dst)


def test_cache_type_is_properly_overridden(tmp_dir, erepo_dir):
Expand Down

0 comments on commit 7d45a55

Please sign in to comment.