From 88f1ada4bf82bb07873d701e3a98cb10f4a76fd4 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:25:28 +0545 Subject: [PATCH] tests: func test for #4344 (#10732) See https://github.com/iterative/dvc-data/pull/601 that fixed the issue. The test is based on reproduction steps from: https://github.com/iterative/dvc/issues/4344#issuecomment-2822000925 --- tests/func/test_checkout.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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"}}