Better error message when using remove on file instead of dvc file

This commit is contained in:
Alex Hall
2022-08-29 01:43:43 +03:00
committed by Ruslan Kuprieiev
parent 9cb242c8a5
commit 8bdf9b1138
3 changed files with 33 additions and 3 deletions
+16 -1
View File
@@ -4,7 +4,10 @@ import pytest
from dvc.cli import main
from dvc.fs import system
from dvc.stage.exceptions import StageFileDoesNotExistError
from dvc.stage.exceptions import (
StageFileDoesNotExistError,
StageFileIsNotDvcFileError,
)
from dvc.utils.fs import remove
from dvc_objects.errors import ObjectDBError
from tests.utils import get_gitignore_content
@@ -32,6 +35,18 @@ def test_remove(tmp_dir, scm, dvc, run_copy, remove_outs):
assert not (tmp_dir / ".gitignore").exists()
def test_remove_file_target(tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
with pytest.raises(
StageFileIsNotDvcFileError,
match="'foo' is not a .dvc file. Do you mean 'foo.dvc'?",
):
dvc.remove("foo")
dvc.remove("foo.dvc")
def test_remove_non_existent_file(tmp_dir, dvc):
with pytest.raises(StageFileDoesNotExistError):
dvc.remove("non_existent_dvc_file.dvc")