From 1dd7d6468a54be56039b2e3a50bcf171d8e854ff Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 23 Nov 2009 14:42:03 +0100 Subject: index.checkout: improved handling of errors as the thrown exception contains exact information about the successfully checked out files as well as the failed ones Return value of the method is an iterator to all checked out files --- test/git/test_index.py | 18 ++++++++++++++---- 1 file changed, 14 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 c937f650..da5ad02c 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -11,6 +11,7 @@ import os import sys import tempfile import glob +import shutil from stat import * @@ -209,19 +210,22 @@ class TestTree(TestBase): # test full checkout test_file = os.path.join(rw_repo.git.git_dir, "CHANGES") - os.remove(test_file) - index.checkout(None, force=True, fprogress=self._fprogress) + open(test_file, 'ab').write("some data") + rval = index.checkout(None, force=True, fprogress=self._fprogress) + assert 'CHANGES' in list(rval) self._assert_fprogress([None]) assert os.path.isfile(test_file) os.remove(test_file) - index.checkout(None, force=False, fprogress=self._fprogress) + rval = index.checkout(None, force=False, fprogress=self._fprogress) + assert 'CHANGES' in list(rval) self._assert_fprogress([None]) assert os.path.isfile(test_file) # individual file os.remove(test_file) - index.checkout(test_file, fprogress=self._fprogress) + rval = index.checkout(test_file, fprogress=self._fprogress) + assert list(rval)[0] == 'CHANGES' self._assert_fprogress([test_file]) assert os.path.exists(test_file) @@ -238,6 +242,7 @@ class TestTree(TestBase): index.checkout(test_file) except CheckoutError, e: assert len(e.failed_files) == 1 and e.failed_files[0] == os.path.basename(test_file) + assert len(e.valid_files) == 0 assert open(test_file).read().endswith(append_data) else: raise AssertionError("Exception CheckoutError not thrown") @@ -245,6 +250,11 @@ class TestTree(TestBase): # if we force it it should work index.checkout(test_file, force=True) assert not open(test_file).read().endswith(append_data) + + # checkout directory + shutil.rmtree(os.path.join(rw_repo.git.git_dir, "lib")) + rval = index.checkout('lib') + assert len(list(rval)) > 1 def _count_existing(self, repo, files): """ -- cgit v1.2.1