summaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-06 14:05:30 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-06 14:05:30 +0100
commita05e49d2419d65c59c65adf5cd8c05f276550e1d (patch)
tree62d8284dbccfee635babe9c46ad5a059f5da0bde /git/test
parent60e54133aa1105a1270f0a42e74813f75cd2dc46 (diff)
downloadgitpython-a05e49d2419d65c59c65adf5cd8c05f276550e1d.tar.gz
test_repo works
Diffstat (limited to 'git/test')
-rw-r--r--git/test/lib/helper.py1
-rw-r--r--git/test/test_index.py1
-rw-r--r--git/test/test_refs.py6
-rw-r--r--git/test/test_repo.py28
-rw-r--r--git/test/test_submodule.py38
5 files changed, 51 insertions, 23 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index eea594e7..bd679512 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -179,6 +179,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
pass
crw.set(section, "receivepack", True)
# release lock
+ crw.release()
del(crw)
# initialize the remote - first do it as local remote and pull, then
diff --git a/git/test/test_index.py b/git/test/test_index.py
index d81d08ef..f7504b32 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -382,6 +382,7 @@ class TestIndex(TestBase):
writer = rw_repo.config_writer()
writer.set_value("user", "name", uname)
writer.set_value("user", "email", umail)
+ writer.release()
# remove all of the files, provide a wild mix of paths, BaseIndexEntries,
# IndexEntries
diff --git a/git/test/test_refs.py b/git/test/test_refs.py
index af33765a..14b91cfe 100644
--- a/git/test/test_refs.py
+++ b/git/test/test_refs.py
@@ -105,9 +105,11 @@ class TestRefs(TestBase):
tv = "testopt"
writer.set_value(tv, 1)
assert writer.get_value(tv) == 1
- del(writer)
+ writer.release()
assert head.config_reader().get_value(tv) == 1
- head.config_writer().remove_option(tv)
+ writer = head.config_writer()
+ writer.remove_option(tv)
+ writer.release()
# after the clone, we might still have a tracking branch setup
head.set_tracking_branch(None)
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index ae824086..f216039e 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -30,7 +30,10 @@ from git import (
from git.util import join_path_native
from git.exc import BadObject
from gitdb.util import bin_to_hex
-from git.compat import string_types
+from git.compat import (
+ string_types,
+ defenc
+)
import os
import sys
@@ -259,13 +262,16 @@ class TestRepo(TestBase):
assert self.rorepo.tag('refs/tags/0.1.5').commit
def test_archive(self):
- tmpfile = os.tmpfile()
- self.rorepo.archive(tmpfile, '0.1.5')
- assert tmpfile.tell()
+ tmpfile = tempfile.mktemp(suffix='archive-test')
+ stream = open(tmpfile, 'wb')
+ self.rorepo.archive(stream, '0.1.5')
+ assert stream.tell()
+ stream.close()
+ os.remove(tmpfile)
@patch.object(Git, '_call_process')
def test_should_display_blame_information(self, git):
- git.return_value = fixture('blame')
+ git.return_value = fixture('blame').decode(defenc)
b = self.rorepo.blame('master', 'lib/git.py')
assert_equal(13, len(b))
assert_equal(2, len(b[0]))
@@ -336,6 +342,7 @@ class TestRepo(TestBase):
try:
writer = self.rorepo.config_writer(config_level)
assert not writer.read_only
+ writer.release()
except IOError:
# its okay not to get a writer for some configuration files if we
# have no permissions
@@ -350,7 +357,8 @@ class TestRepo(TestBase):
tag = self.rorepo.create_tag("new_tag", "HEAD~2")
self.rorepo.delete_tag(tag)
- self.rorepo.config_writer()
+ writer = self.rorepo.config_writer()
+ writer.release()
remote = self.rorepo.create_remote("new_remote", "git@server:repo.git")
self.rorepo.delete_remote(remote)
@@ -365,7 +373,7 @@ class TestRepo(TestBase):
l1 = b"0123456789\n"
l2 = b"abcdefghijklmnopqrstxy\n"
l3 = b"z\n"
- d = b"%s%s%s\n" % (l1, l2, l3)
+ d = l1 + l2 + l3 + b"\n"
l1p = l1[:5]
@@ -382,7 +390,7 @@ class TestRepo(TestBase):
# readlines no limit
s = mkfull()
lines = s.readlines()
- assert len(lines) == 3 and lines[-1].endswith('\n')
+ assert len(lines) == 3 and lines[-1].endswith(b'\n')
assert s._stream.tell() == len(d) # must have scrubbed to the end
# realines line limit
@@ -566,7 +574,7 @@ class TestRepo(TestBase):
# try partial parsing
max_items = 40
for i, binsha in enumerate(self.rorepo.odb.sha_iter()):
- assert rev_parse(bin_to_hex(binsha)[:8 - (i % 2)]).binsha == binsha
+ assert rev_parse(bin_to_hex(binsha)[:8 - (i % 2)].decode('ascii')).binsha == binsha
if i > max_items:
# this is rather slow currently, as rev_parse returns an object
# which requires accessing packs, it has some additional overhead
@@ -645,6 +653,6 @@ class TestRepo(TestBase):
assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
# Test using an absolute gitdir path in the .git file.
- open(git_file_path, 'wb').write('gitdir: %s\n' % real_path_abs)
+ open(git_file_path, 'wb').write(('gitdir: %s\n' % real_path_abs).encode('ascii'))
git_file_repo = Repo(rwrepo.working_tree_dir)
assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index 8c1580fe..499d6bac 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -99,7 +99,7 @@ class TestSubmodule(TestBase):
# for faster checkout, set the url to the local path
new_smclone_path = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path))
writer.set_value('url', new_smclone_path)
- del(writer)
+ writer.release()
assert sm.config_reader().get_value('url') == new_smclone_path
assert sm.url == new_smclone_path
# END handle bare repo
@@ -196,7 +196,9 @@ class TestSubmodule(TestBase):
# adjust the path of the submodules module to point to the local destination
new_csmclone_path = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path, csm.path))
- csm.config_writer().set_value('url', new_csmclone_path)
+ writer = csm.config_writer()
+ writer.set_value('url', new_csmclone_path)
+ writer.release()
assert csm.url == new_csmclone_path
# dry-run does nothing
@@ -257,8 +259,12 @@ class TestSubmodule(TestBase):
# NOTE: As we did a few updates in the meanwhile, the indices were reset
# Hence we create some changes
csm.set_parent_commit(csm.repo.head.commit)
- sm.config_writer().set_value("somekey", "somevalue")
- csm.config_writer().set_value("okey", "ovalue")
+ writer = sm.config_writer()
+ writer.set_value("somekey", "somevalue")
+ writer.release()
+ writer = csm.config_writer()
+ writer.set_value("okey", "ovalue")
+ writer.release()
self.failUnlessRaises(InvalidGitRepositoryError, sm.remove)
# if we remove the dirty index, it would work
sm.module().index.reset()
@@ -406,7 +412,8 @@ class TestSubmodule(TestBase):
assert len(rm.list_items(rm.module())) == 1
rm.config_reader()
- rm.config_writer()
+ w = rm.config_writer()
+ w.release()
# deep traversal gitdb / async
rsmsp = [sm.path for sm in rm.traverse()]
@@ -431,8 +438,9 @@ class TestSubmodule(TestBase):
assert not sm.module_exists() # was never updated after rwrepo's clone
# assure we clone from a local source
- sm.config_writer().set_value(
- 'url', to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path)))
+ writer = sm.config_writer()
+ writer.set_value('url', to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, sm.path)))
+ writer.release()
# dry-run does nothing
sm.update(recursive=False, dry_run=True, progress=prog)
@@ -440,7 +448,9 @@ class TestSubmodule(TestBase):
sm.update(recursive=False)
assert sm.module_exists()
- sm.config_writer().set_value('path', fp) # change path to something with prefix AFTER url change
+ writer = sm.config_writer()
+ writer.set_value('path', fp) # change path to something with prefix AFTER url change
+ writer.release()
# update fails as list_items in such a situations cannot work, as it cannot
# find the entry at the changed path
@@ -504,7 +514,9 @@ class TestSubmodule(TestBase):
# repository at the different url
nsm.set_parent_commit(csmremoved)
nsmurl = to_native_path_linux(join_path_native(self.rorepo.working_tree_dir, rsmsp[0]))
- nsm.config_writer().set_value('url', nsmurl)
+ writer = nsm.config_writer()
+ writer.set_value('url', nsmurl)
+ writer.release()
csmpathchange = rwrepo.index.commit("changed url")
nsm.set_parent_commit(csmpathchange)
@@ -532,7 +544,9 @@ class TestSubmodule(TestBase):
nsmm = nsm.module()
prev_commit = nsmm.head.commit
for branch in ("some_virtual_branch", cur_branch.name):
- nsm.config_writer().set_value(Submodule.k_head_option, git.Head.to_full_path(branch))
+ writer = nsm.config_writer()
+ writer.set_value(Submodule.k_head_option, git.Head.to_full_path(branch))
+ writer.release()
csmbranchchange = rwrepo.index.commit("changed branch to %s" % branch)
nsm.set_parent_commit(csmbranchchange)
# END for each branch to change
@@ -560,7 +574,9 @@ class TestSubmodule(TestBase):
assert nsm.exists() and nsm.module_exists() and len(nsm.children()) >= 1
# assure we pull locally only
nsmc = nsm.children()[0]
- nsmc.config_writer().set_value('url', async_url)
+ writer = nsmc.config_writer()
+ writer.set_value('url', async_url)
+ writer.release()
rm.update(recursive=True, progress=prog, dry_run=True) # just to run the code
rm.update(recursive=True, progress=prog)