From 3bee808e15707d849c00e8cea8106e41dd96d771 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 23 Nov 2009 11:14:28 +0100 Subject: index.checkout: Now parsing stderror in the end to determine which files have not been updated as they where modified locally or did not exist. Test was improved to check for this new case. --- test/git/test_index.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'test/git/test_index.py') diff --git a/test/git/test_index.py b/test/git/test_index.py index 2a07ae97..c937f650 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -225,10 +225,26 @@ class TestTree(TestBase): self._assert_fprogress([test_file]) assert os.path.exists(test_file) - # checking out non-existing file is ignored/doesn't raise - index.checkout("doesnt_exist_ever.txt.that") - index.checkout(paths=["doesnt/exist"]) - + # checking out non-existing file throws + self.failUnlessRaises(CheckoutError, index.checkout, "doesnt_exist_ever.txt.that") + self.failUnlessRaises(CheckoutError, index.checkout, paths=["doesnt/exist"]) + + # checkout file with modifications + append_data = "hello" + fp = open(test_file, "ab") + fp.write(append_data) + fp.close() + try: + index.checkout(test_file) + except CheckoutError, e: + assert len(e.failed_files) == 1 and e.failed_files[0] == os.path.basename(test_file) + assert open(test_file).read().endswith(append_data) + else: + raise AssertionError("Exception CheckoutError not thrown") + + # if we force it it should work + index.checkout(test_file, force=True) + assert not open(test_file).read().endswith(append_data) def _count_existing(self, repo, files): """ -- cgit v1.2.1