Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dberenbaum committed Aug 11, 2023
1 parent f55fb53 commit 372b317
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
24 changes: 24 additions & 0 deletions tests/func/repro/test_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,3 +1366,27 @@ def test_repro_ignore_errors(mocker, tmp_dir, dvc, copy_script):
[bar_call, stage1_call, foo_call, stage2_call],
[foo_call, bar_call, stage1_call, stage2_call],
)


@pytest.mark.parametrize("persist", [True, False])
def test_repro_external_outputs(tmp_dir, dvc, local_workspace, persist):
local_workspace.gen("foo", "foo")
foo_path = str(local_workspace / "foo")
bar_path = str(local_workspace / "bar")
outs = {"outs_no_cache": [bar_path]}
if persist:
outs = {"outs_persist_no_cache": [bar_path]}
dvc.run(
name="mystage",
cmd=f"cp {foo_path} {bar_path}",
deps=[foo_path],
no_exec=True,
**outs,
)

dvc.reproduce()
dvc.reproduce(force=True)

assert (local_workspace / "foo").read_text() == "foo"
assert (local_workspace / "bar").read_text() == "foo"
assert not (local_workspace / "cache").exists()
14 changes: 6 additions & 8 deletions tests/func/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,22 +520,22 @@ def test_run_overwrite_preserves_meta_and_comment(tmp_dir, dvc, run_copy):
assert (tmp_dir / PROJECT_FILE).read_text() == text.format(src="foo1", dest="bar1")


@pytest.mark.parametrize("persist", [True, False])
def test_run_external_outputs(tmp_dir, dvc, local_workspace, persist):
def test_run_external_outputs(
tmp_dir,
dvc,
local_workspace,
):
hash_name = "md5"
foo_hash = "acbd18db4cc2f85cedef654fccc4a4d8"
bar_hash = "37b51d194a7513e45b56f6524f2d51f2"

local_workspace.gen("foo", "foo")
outs = {"outs_no_cache": ["remote://workspace/bar"]}
if persist:
outs = {"outs_persist_no_cache": ["remote://workspace/bar"]}
dvc.run(
name="mystage",
cmd="mycmd",
deps=["remote://workspace/foo"],
outs_no_cache=["remote://workspace/bar"],
no_exec=True,
**outs,
)

dvc_yaml = (
Expand All @@ -548,8 +548,6 @@ def test_run_external_outputs(tmp_dir, dvc, local_workspace, persist):
" - remote://workspace/bar:\n"
" cache: false\n"
)
if persist:
dvc_yaml += " persist: true\n"

assert (tmp_dir / "dvc.yaml").read_text() == dvc_yaml
assert not (tmp_dir / "dvc.lock").exists()
Expand Down

0 comments on commit 372b317

Please sign in to comment.