def test_add_multiple_with_exception(tmp_dir, scm, dvc, mocker):
tmp_dir.gen({"file": "file content", "other": "other file content"})
original_move = dvc.cache.local.tree.move
def raise_move(from_info, to_info, mode=None):
if str(from_info) == "other":
raise Exception
else:
original_move(from_info, to_info, mode)
assert not (tmp_dir / ".gitignore").exists()
mocker.patch.object(dvc.cache.local.tree, "move", side_effect=raise_move)
try:
dvc.add(["file", "other"])
except:
pass
assert (tmp_dir / "file.dvc").exists()
assert (tmp_dir / ".gitignore").exists()
assert (tmp_dir / ".gitignore").read_text() == ''
Following test passes:
How it should be?
.gitignoreshould containfileeven though the wholeaddcommand failed. As of now, we end up successfully addingfileto dvc but it is not ignored. At least we should be informed about potential problems.