From b7b7eff4a3c6511bece2fa5348fc0c8388e4eb1f Mon Sep 17 00:00:00 2001 From: David de la Iglesia Castro Date: Thu, 16 Feb 2023 10:21:35 +0100 Subject: [PATCH] tests: Fix test_deleted. Closes #6297 #9017 actually fixed this but the test was incorrect (something wrong with caplog). --- tests/func/experiments/test_stash_exp.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/func/experiments/test_stash_exp.py b/tests/func/experiments/test_stash_exp.py index 1123af6461..68895cf666 100644 --- a/tests/func/experiments/test_stash_exp.py +++ b/tests/func/experiments/test_stash_exp.py @@ -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") @@ -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()