summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/git/test_index.py6
-rw-r--r--test/testlib/helper.py17
2 files changed, 14 insertions, 9 deletions
diff --git a/test/git/test_index.py b/test/git/test_index.py
index 35580135..929d40a3 100644
--- a/test/git/test_index.py
+++ b/test/git/test_index.py
@@ -182,6 +182,9 @@ class TestIndex(TestBase):
index.write()
assert rw_repo.index.entries[manifest_key].hexsha == Diff.NULL_HEX_SHA
+ # write an unchanged index ( just for the fun of it )
+ rw_repo.index.write()
+
# a three way merge would result in a conflict and fails as the command will
# not overwrite any entries in our index and hence leave them unmerged. This is
# mainly a protection feature as the current index is not yet in a tree
@@ -432,6 +435,7 @@ class TestIndex(TestBase):
# same file
entries = index.reset(new_commit).add(['lib/git/head.py']*2, fprogress=self._fprogress_add)
+ assert entries[0].mode & 0644 == 0644
# would fail, test is too primitive to handle this case
# self._assert_fprogress(entries)
self._reset_progress()
@@ -574,7 +578,7 @@ class TestIndex(TestBase):
@with_rw_repo('HEAD')
def test_compare_write_tree(self, rw_repo):
def write_tree(index):
- tree_sha = index.repo.git.write_tree(missing_ok=True)
+ tree_sha = index.write_tree().sha
return Tree(index.repo, tree_sha, 0, '')
# END git cmd write tree
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index ebff57f6..3a5d7b8f 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -70,7 +70,7 @@ def with_bare_rw_repo(func):
Use this if you want to make purely index based adjustments, change refs, create
heads, generally operations that do not need a working tree."""
def bare_repo_creator(self):
- repo_dir = tempfile.mktemp("bare_repo")
+ repo_dir = tempfile.mktemp("bare_repo_%s" % func.__name__)
rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=True)
prev_cwd = os.getcwd()
try:
@@ -96,7 +96,7 @@ def with_rw_repo(working_tree_ref):
assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout"
def argument_passer(func):
def repo_creator(self):
- repo_dir = tempfile.mktemp("non_bare_repo")
+ repo_dir = tempfile.mktemp("non_bare_%s" % func.__name__)
rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=False, n=True)
rw_repo.head.commit = working_tree_ref
@@ -105,11 +105,12 @@ def with_rw_repo(working_tree_ref):
prev_cwd = os.getcwd()
os.chdir(rw_repo.working_dir)
try:
- return func(self, rw_repo)
- except:
- print >> sys.stderr, "Keeping repo after failure: %s" % repo_dir
- raise
- else:
+ try:
+ return func(self, rw_repo)
+ except:
+ print >> sys.stderr, "Keeping repo after failure: %s" % repo_dir
+ raise
+ finally:
os.chdir(prev_cwd)
rw_repo.git.clear_cache()
shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
@@ -146,7 +147,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout"
def argument_passer(func):
def remote_repo_creator(self):
- remote_repo_dir = tempfile.mktemp("remote_repo")
+ remote_repo_dir = tempfile.mktemp("remote_repo_%s" % func.__name__)
repo_dir = tempfile.mktemp("remote_clone_non_bare_repo")
rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True)