Skip to content

Commit

Permalink
tests: Fix test_deleted.
Browse files Browse the repository at this point in the history
Closes #6297
#9017 actually fixed this but the test was incorrect (something wrong with caplog).
  • Loading branch information
daavoo committed Feb 16, 2023
1 parent ddeb32e commit b7b7eff
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tests/func/experiments/test_stash_exp.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import logging

import pytest
from funcy import first

from dvc.dependency.base import DependencyDoesNotExistError
from dvc.exceptions import ReproductionError


@pytest.mark.parametrize("tmp", [True, False])
@pytest.mark.parametrize("staged", [True, False])
def test_deleted(tmp_dir, scm, dvc, caplog, tmp, staged):
if not tmp:
pytest.xfail("TODO: https://github.com/iterative/dvc/issues/6297")

def test_deleted(tmp_dir, scm, dvc, tmp, staged):
tmp_dir.scm_gen("file", "file", commit="commit file")
stage = dvc.stage.add(
cmd="cat file",
deps=["file"],
name="foo",
)
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
Expand All @@ -24,11 +21,11 @@ def test_deleted(tmp_dir, scm, dvc, caplog, tmp, staged):
if staged:
scm.add(["file"])

with caplog.at_level(logging.ERROR):
with pytest.raises(ReproductionError):
dvc.experiments.run(stage.addressing, tmp_dir=tmp)
assert "failed to reproduce 'foo'" in caplog.text
with pytest.raises(ReproductionError) as exc_info:
dvc.experiments.run(stage.addressing, tmp_dir=tmp)

cause = exc_info._excinfo[1].__cause__
assert isinstance(cause, DependencyDoesNotExistError)
assert not file.exists()


Expand Down

0 comments on commit b7b7eff

Please sign in to comment.