Files
dvc/tests/unit/cli/test_main.py
T
skshetry b3fb0dfdad dvc.objects: extend diskcache to handle pickle errors (#7734)
dvc.objects: extend diskcache to handle pickle errors
2022-05-12 21:12:33 +05:45

27 lines
716 B
Python

from argparse import Namespace
from funcy import raiser
from dvc.cli import main
from dvc.objects.cache import DiskError
def test_state_pickle_errors_are_correctly_raised(tmp_dir, caplog, mocker):
path = tmp_dir / "dir" / "test"
mocker.patch(
"dvc.cli.parse_args",
return_value=Namespace(
func=raiser(DiskError(path, "md5s")),
quiet=False,
verbose=True,
),
)
assert main() == 255
assert (
f"Could not open pickled 'md5s' cache.\n"
f"Remove the '{path.relative_to(tmp_dir)}' directory "
"and then retry this command.\n"
"See <https://error.dvc.org/pickle> for more information."
) in caplog.text