From 8c8b585de9d857e7aefc836aec7bb0cfc7998e75 Mon Sep 17 00:00:00 2001 From: Andrew Grigorev Date: Wed, 20 Mar 2019 13:22:24 +0300 Subject: [PATCH] tests: test_install commit and clean Uncommited files wouldn't be accessible as git objects. It needs `git clean -fd` to amend "Working Tree" metrics collection which took its part when the git tree is dirty. --- tests/test_install.py | 2 ++ tests/test_metrics.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_install.py b/tests/test_install.py index ec865b72e..54cf8f80f 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -20,6 +20,8 @@ class TestInstall(TestDvc): self.assertTrue(os.path.isfile(hook("pre-commit"))) self.dvc.add(self.FOO) + self.dvc.scm.add([".gitignore", self.FOO + ".dvc"]) + self.dvc.scm.commit("add") os.unlink(self.FOO) self.dvc.scm.checkout("branch", create_new=True) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 78456381b..9f4157f8b 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -489,7 +489,7 @@ class TestCachedMetrics(TestDvc): self.assertIsNotNone(stage) self.assertEqual(stage.relpath, "metrics.json.dvc") - self.dvc.scm.add([".gitignore", "metrics.json.dvc"]) + self.dvc.scm.add(["code.py", ".gitignore", "metrics.json.dvc"]) self.dvc.scm.commit(branch) def _test_metrics(self, func): @@ -502,6 +502,10 @@ class TestCachedMetrics(TestDvc): func("one") func("two") + # TestDvc currently is based on TestGit, so it is safe to use + # scm.git for now + self.dvc.scm.git.git.clean("-fd") + self.dvc = DvcRepo(".") res = self.dvc.metrics.show(