diff --git a/tests/func/test_checkout.py b/tests/func/test_checkout.py index 1781aecda..3608d362f 100644 --- a/tests/func/test_checkout.py +++ b/tests/func/test_checkout.py @@ -744,3 +744,12 @@ def test_checkout_dir_compat(tmp_dir, dvc): remove("data") dvc.checkout() assert (tmp_dir / "data").read_text() == {"foo": "foo"} + + +def test_checkout_cleanup_properly_on_untracked_nested_directories(tmp_dir, scm, dvc): + tmp_dir.dvc_gen({"datasets": {"dir1": {"file1": "file1"}}}) + tmp_dir.gen({"datasets": {"dir2": {"dir3": {"file2": "file2"}}}}) + + dvc.checkout(force=True) + + assert (tmp_dir / "datasets").read_text() == {"dir1": {"file1": "file1"}}