summaryrefslogtreecommitdiff
path: root/test/git/test_index.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-11-23 11:14:28 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-11-23 11:34:38 +0100
commit3bee808e15707d849c00e8cea8106e41dd96d771 (patch)
tree7f255aa6524409a9b566ad78318b1f4f89334aae /test/git/test_index.py
parent331ddc27a22bde33542f8c1a00b6b56da32e5033 (diff)
downloadgitpython-3bee808e15707d849c00e8cea8106e41dd96d771.tar.gz
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.
Diffstat (limited to 'test/git/test_index.py')
-rw-r--r--test/git/test_index.py24
1 files changed, 20 insertions, 4 deletions
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):
"""