summaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
authorAntoine Musso <hashar@free.fr>2014-11-16 20:56:53 +0100
committerAntoine Musso <hashar@free.fr>2014-11-16 21:05:53 +0100
commit614907b7445e2ed8584c1c37df7e466e3b56170f (patch)
tree4b6e09110cd356799e9fa0f188fae55e5fa81fca /git/test
parentbe34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 (diff)
downloadgitpython-614907b7445e2ed8584c1c37df7e466e3b56170f.tar.gz
pep8 linting (whitespace before/after)
E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals
Diffstat (limited to 'git/test')
-rw-r--r--git/test/lib/__init__.py4
-rw-r--r--git/test/lib/helper.py2
-rw-r--r--git/test/performance/test_commit.py8
-rw-r--r--git/test/performance/test_odb.py4
-rw-r--r--git/test/performance/test_streams.py6
-rw-r--r--git/test/performance/test_utils.py16
-rw-r--r--git/test/test_actor.py2
-rw-r--r--git/test/test_base.py20
-rw-r--r--git/test/test_blob.py2
-rw-r--r--git/test/test_commit.py10
-rw-r--r--git/test/test_config.py8
-rw-r--r--git/test/test_diff.py10
-rw-r--r--git/test/test_fun.py10
-rw-r--r--git/test/test_git.py14
-rw-r--r--git/test/test_index.py38
-rw-r--r--git/test/test_reflog.py6
-rw-r--r--git/test/test_refs.py44
-rw-r--r--git/test/test_remote.py26
-rw-r--r--git/test/test_repo.py58
-rw-r--r--git/test/test_submodule.py8
-rw-r--r--git/test/test_tree.py18
-rw-r--r--git/test/test_util.py6
22 files changed, 160 insertions, 160 deletions
diff --git a/git/test/lib/__init__.py b/git/test/lib/__init__.py
index 77512794..e13e227d 100644
--- a/git/test/lib/__init__.py
+++ b/git/test/lib/__init__.py
@@ -9,5 +9,5 @@ from mock import *
from asserts import *
from helper import *
-__all__ = [ name for name, obj in locals().items()
- if not (name.startswith('_') or inspect.ismodule(obj)) ]
+__all__ = [name for name, obj in locals().items()
+ if not (name.startswith('_') or inspect.ismodule(obj))]
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index d5045ad7..812aecdc 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -188,7 +188,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
# try to list remotes to diagnoes whether the server is up
try:
rw_repo.git.ls_remote(d_remote)
- except GitCommandError,e:
+ except GitCommandError, e:
print str(e)
if os.name == 'nt':
raise AssertionError('git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"' % os.path.dirname(_mktemp()))
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py
index 79555844..adee2567 100644
--- a/git/test/performance/test_commit.py
+++ b/git/test/performance/test_commit.py
@@ -46,7 +46,7 @@ class TestPerformance(TestBigRepoRW):
# END for each object
# END for each commit
elapsed_time = time() - st
- print >> sys.stderr, "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % (nc, no, elapsed_time, no/elapsed_time)
+ print >> sys.stderr, "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % (nc, no, elapsed_time, no / elapsed_time)
def test_commit_traversal(self):
# bound to cat-file parsing performance
@@ -57,7 +57,7 @@ class TestPerformance(TestBigRepoRW):
self._query_commit_info(c)
# END for each traversed commit
elapsed_time = time() - st
- print >> sys.stderr, "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc/elapsed_time)
+ print >> sys.stderr, "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
def test_commit_iteration(self):
# bound to stream parsing performance
@@ -68,7 +68,7 @@ class TestPerformance(TestBigRepoRW):
self._query_commit_info(c)
# END for each traversed commit
elapsed_time = time() - st
- print >> sys.stderr, "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc/elapsed_time)
+ print >> sys.stderr, "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
def test_commit_serialization(self):
assert_commit_serialization(self.gitrwrepo, self.head_sha_2k, True)
@@ -83,7 +83,7 @@ class TestPerformance(TestBigRepoRW):
nc = 5000
st = time()
for i in xrange(nc):
- cm = Commit( rwrepo, Commit.NULL_BIN_SHA, hc.tree,
+ cm = Commit(rwrepo, Commit.NULL_BIN_SHA, hc.tree,
hc.author, hc.authored_date, hc.author_tz_offset,
hc.committer, hc.committed_date, hc.committer_tz_offset,
str(i), parents=hc.parents, encoding=hc.encoding)
diff --git a/git/test/performance/test_odb.py b/git/test/performance/test_odb.py
index 57a953ab..5ddbbd53 100644
--- a/git/test/performance/test_odb.py
+++ b/git/test/performance/test_odb.py
@@ -12,7 +12,7 @@ from lib import (
class TestObjDBPerformance(TestBigRepoR):
def test_random_access(self):
- results = [ ["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"] ]
+ results = [["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"]]
for repo in (self.gitrorepo, self.puregitrorepo):
# GET COMMITS
st = time()
@@ -60,7 +60,7 @@ class TestObjDBPerformance(TestBigRepoR):
# END for each bloblist
elapsed = time() - st
- print >> sys.stderr, "%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )" % (type(repo.odb), nb, data_bytes/1000, elapsed, nb / elapsed, (data_bytes / 1000) / elapsed)
+ print >> sys.stderr, "%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )" % (type(repo.odb), nb, data_bytes / 1000, elapsed, nb / elapsed, (data_bytes / 1000) / elapsed)
results[2].append(elapsed)
# END for each repo type
diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py
index c8b59da6..32ae98bf 100644
--- a/git/test/performance/test_streams.py
+++ b/git/test/performance/test_streams.py
@@ -19,8 +19,8 @@ from lib import (
class TestObjDBPerformance(TestBigRepoR):
- large_data_size_bytes = 1000*1000*10 # some MiB should do it
- moderate_data_size_bytes = 1000*1000*1 # just 1 MiB
+ large_data_size_bytes = 1000 * 1000 * 10 # some MiB should do it
+ moderate_data_size_bytes = 1000 * 1000 * 1 # just 1 MiB
@with_rw_repo('HEAD', bare=True)
def test_large_data_streaming(self, rwrepo):
@@ -58,7 +58,7 @@ class TestObjDBPerformance(TestBigRepoR):
print >> sys.stderr, "Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)" % (size_kib, desc, elapsed_readall, size_kib / elapsed_readall)
# reading in chunks of 1 MiB
- cs = 512*1000
+ cs = 512 * 1000
chunks = list()
st = time()
ostream = ldb.stream(binsha)
diff --git a/git/test/performance/test_utils.py b/git/test/performance/test_utils.py
index 4979eaa1..19c37a5f 100644
--- a/git/test/performance/test_utils.py
+++ b/git/test/performance/test_utils.py
@@ -65,7 +65,7 @@ class TestUtilPerformance(TestBigRepoR):
def test_instantiation(self):
ni = 100000
max_num_items = 4
- for mni in range(max_num_items+1):
+ for mni in range(max_num_items + 1):
for cls in (tuple, list):
st = time()
for i in xrange(ni):
@@ -74,11 +74,11 @@ class TestUtilPerformance(TestBigRepoR):
elif mni == 1:
cls((1,))
elif mni == 2:
- cls((1,2))
+ cls((1, 2))
elif mni == 3:
- cls((1,2,3))
+ cls((1, 2, 3))
elif mni == 4:
- cls((1,2,3,4))
+ cls((1, 2, 3, 4))
else:
cls(x for x in xrange(mni))
# END handle empty cls
@@ -91,22 +91,22 @@ class TestUtilPerformance(TestBigRepoR):
# tuple and tuple direct
st = time()
for i in xrange(ni):
- t = (1,2,3,4)
+ t = (1, 2, 3, 4)
# END for each item
elapsed = time() - st
print >> sys.stderr, "Created %i tuples (1,2,3,4) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed)
st = time()
for i in xrange(ni):
- t = tuple((1,2,3,4))
+ t = tuple((1, 2, 3, 4))
# END for each item
elapsed = time() - st
print >> sys.stderr, "Created %i tuples tuple((1,2,3,4)) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed)
def test_unpacking_vs_indexing(self):
ni = 1000000
- list_items = [1,2,3,4]
- tuple_items = (1,2,3,4)
+ list_items = [1, 2, 3, 4]
+ tuple_items = (1, 2, 3, 4)
for sequence in (list_items, tuple_items):
st = time()
diff --git a/git/test/test_actor.py b/git/test/test_actor.py
index 40e307ba..5ccf1d2e 100644
--- a/git/test/test_actor.py
+++ b/git/test/test_actor.py
@@ -18,7 +18,7 @@ class TestActor(object):
# base type capabilities
assert a == a
- assert not ( a != a )
+ assert not (a != a)
m = set()
m.add(a)
m.add(a)
diff --git a/git/test/test_base.py b/git/test/test_base.py
index 42b95b39..211c7479 100644
--- a/git/test/test_base.py
+++ b/git/test/test_base.py
@@ -18,10 +18,10 @@ import tempfile
class TestBase(TestBase):
- type_tuples = ( ("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"),
+ type_tuples = (("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"),
("tree", "3a6a5e3eeed3723c09f1ef0399f81ed6b8d82e79", "directory"),
("commit", "4251bd59fb8e11e40c40548cba38180a9536118c", None),
- ("tag", "e56a60e8e9cd333cfba0140a77cd12b0d9398f10", None) )
+ ("tag", "e56a60e8e9cd333cfba0140a77cd12b0d9398f10", None))
def test_base_object(self):
# test interface of base object classes
@@ -35,9 +35,9 @@ class TestBase(TestBase):
binsha = hex_to_bin(hexsha)
item = None
if path is None:
- item = obj_type(self.rorepo,binsha)
+ item = obj_type(self.rorepo, binsha)
else:
- item = obj_type(self.rorepo,binsha, 0, path)
+ item = obj_type(self.rorepo, binsha, 0, path)
# END handle index objects
num_objs += 1
assert item.hexsha == hexsha
@@ -51,7 +51,7 @@ class TestBase(TestBase):
if isinstance(item, base.IndexObject):
num_index_objs += 1
- if hasattr(item,'path'): # never runs here
+ if hasattr(item, 'path'): # never runs here
assert not item.path.startswith("/") # must be relative
assert isinstance(item.mode, int)
# END index object check
@@ -70,7 +70,7 @@ class TestBase(TestBase):
# each has a unique sha
assert len(s) == num_objs
- assert len(s|s) == num_objs
+ assert len(s | s) == num_objs
assert num_index_objs == 2
def test_get_object_type_by_name(self):
@@ -78,7 +78,7 @@ class TestBase(TestBase):
assert base.Object in get_object_type_by_name(tname).mro()
# END for each known type
- assert_raises( ValueError, get_object_type_by_name, "doesntexist" )
+ assert_raises(ValueError, get_object_type_by_name, "doesntexist")
def test_object_resolution(self):
# objects must be resolved to shas so they compare equal
@@ -87,15 +87,15 @@ class TestBase(TestBase):
@with_rw_repo('HEAD', bare=True)
def test_with_bare_rw_repo(self, bare_rw_repo):
assert bare_rw_repo.config_reader("repository").getboolean("core", "bare")
- assert os.path.isfile(os.path.join(bare_rw_repo.git_dir,'HEAD'))
+ assert os.path.isfile(os.path.join(bare_rw_repo.git_dir, 'HEAD'))
@with_rw_repo('0.1.6')
def test_with_rw_repo(self, rw_repo):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
- assert os.path.isdir(os.path.join(rw_repo.working_tree_dir,'lib'))
+ assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
@with_rw_and_rw_remote_repo('0.1.6')
def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
- assert os.path.isdir(os.path.join(rw_repo.working_tree_dir,'lib'))
+ assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
diff --git a/git/test/test_blob.py b/git/test/test_blob.py
index a1d95ac2..ddd2893f 100644
--- a/git/test/test_blob.py
+++ b/git/test/test_blob.py
@@ -16,7 +16,7 @@ class TestBlob(TestBase):
assert_equal("image/png", blob.mime_type)
def test_mime_type_should_return_text_plain_for_unknown_types(self):
- blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA,'path': 'something'})
+ blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'something'})
assert_equal("text/plain", blob.mime_type)
def test_nodict(self):
diff --git a/git/test/test_commit.py b/git/test/test_commit.py
index d6e13762..7bb019f4 100644
--- a/git/test/test_commit.py
+++ b/git/test/test_commit.py
@@ -62,7 +62,7 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False)
elapsed = time.time() - st
if print_performance_info:
- print >> sys.stderr, "Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s" % (ns, nds, elapsed, ns/elapsed, nds/elapsed)
+ print >> sys.stderr, "Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s" % (ns, nds, elapsed, ns / elapsed, nds / elapsed)
# END handle performance info
@@ -151,10 +151,10 @@ class TestCommit(TestBase):
assert len(list(start.traverse(ignore_self=False, depth=0))) == 1
# prune
- assert start.traverse(branch_first=1, prune=lambda i,d: i == p0).next() == p1
+ assert start.traverse(branch_first=1, prune=lambda i, d: i == p0).next() == p1
# predicate
- assert start.traverse(branch_first=1, predicate=lambda i,d: i == p1).next() == p1
+ assert start.traverse(branch_first=1, predicate=lambda i, d: i == p1).next() == p1
# traversal should stop when the beginning is reached
self.failUnlessRaises(StopIteration, first.traverse().next)
@@ -205,7 +205,7 @@ class TestCommit(TestBase):
assert_equal(sha1, commit.hexsha)
def test_count(self):
- assert self.rorepo.tag('refs/tags/0.1.5').commit.count( ) == 143
+ assert self.rorepo.tag('refs/tags/0.1.5').commit.count() == 143
def test_list(self):
assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)[hex_to_bin('5117c9c8a4d3af19a9958677e45cda9269de1541')], Commit)
@@ -221,7 +221,7 @@ class TestCommit(TestBase):
def test_equality(self):
commit1 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
commit2 = Commit(self.rorepo, Commit.NULL_BIN_SHA)
- commit3 = Commit(self.rorepo, "\1"*20)
+ commit3 = Commit(self.rorepo, "\1" * 20)
assert_equal(commit1, commit2)
assert_not_equal(commit2, commit3)
diff --git a/git/test/test_config.py b/git/test/test_config.py
index cd1c43ed..de4727e0 100644
--- a/git/test/test_config.py
+++ b/git/test/test_config.py
@@ -27,7 +27,7 @@ class TestBase(TestCase):
for filename in ("git_config", "git_config_global"):
file_obj = self._to_memcache(fixture_path(filename))
file_obj_orig = copy(file_obj)
- w_config = GitConfigParser(file_obj, read_only = False)
+ w_config = GitConfigParser(file_obj, read_only=False)
w_config.read() # enforce reading
assert w_config._sections
w_config.write() # enforce writing
@@ -36,7 +36,7 @@ class TestBase(TestCase):
assert file_obj.getvalue() != file_obj_orig.getvalue()
# creating an additional config writer must fail due to exclusive access
- self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only = False)
+ self.failUnlessRaises(IOError, GitConfigParser, file_obj, read_only=False)
# should still have a lock and be able to make changes
assert w_config._lock._has_lock()
@@ -48,7 +48,7 @@ class TestBase(TestCase):
w_config.add_section(sname)
assert w_config.has_section(sname)
w_config.set(sname, oname, val)
- assert w_config.has_option(sname,oname)
+ assert w_config.has_option(sname, oname)
assert w_config.get(sname, oname) == val
sname_new = "new_section"
@@ -88,7 +88,7 @@ class TestBase(TestCase):
# writing must fail
self.failUnlessRaises(IOError, r_config.set, section, option, None)
- self.failUnlessRaises(IOError, r_config.remove_option, section, option )
+ self.failUnlessRaises(IOError, r_config.remove_option, section, option)
# END for each option
self.failUnlessRaises(IOError, r_config.remove_section, section)
# END for each section
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
index 3c2537da..aacd9368 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
@@ -50,7 +50,7 @@ class TestDiff(TestBase):
# be able to deal with it
fixtures = ("diff_2", "diff_2f", "diff_f", "diff_i", "diff_mode_only",
"diff_new_mode", "diff_numstat", "diff_p", "diff_rename",
- "diff_tree_numstat_root" )
+ "diff_tree_numstat_root")
for fixture_name in fixtures:
diff_proc = StringProcessAdapter(fixture(fixture_name))
@@ -62,7 +62,7 @@ class TestDiff(TestBase):
assertion_map = dict()
for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=2)):
diff_item = commit
- if i%2 == 0:
+ if i % 2 == 0:
diff_item = commit.tree
# END use tree every second item
@@ -75,9 +75,9 @@ class TestDiff(TestBase):
if diff_index:
self._assert_diff_format(diff_index)
for ct in DiffIndex.change_type:
- key = 'ct_%s'%ct
+ key = 'ct_%s' % ct
assertion_map.setdefault(key, 0)
- assertion_map[key] = assertion_map[key]+len(list(diff_index.iter_change_type(ct)))
+ assertion_map[key] = assertion_map[key] + len(list(diff_index.iter_change_type(ct)))
# END for each changetype
# check entries
@@ -96,7 +96,7 @@ class TestDiff(TestBase):
# assert we could always find at least one instance of the members we
# can iterate in the diff index - if not this indicates its not working correctly
# or our test does not span the whole range of possibilities
- for key,value in assertion_map.items():
+ for key, value in assertion_map.items():
assert value, "Did not find diff for %s" % key
# END for each iteration type
diff --git a/git/test/test_fun.py b/git/test/test_fun.py
index f435f31b..9d6f3ea4 100644
--- a/git/test/test_fun.py
+++ b/git/test/test_fun.py
@@ -65,7 +65,7 @@ class TestFun(TestBase):
self._assert_index_entries(aggressive_tree_merge(odb, trees), trees)
# too many trees
- self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees*2)
+ self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees * 2)
def mktree(self, odb, entries):
"""create a tree from the given tree entries and safe it to the database"""
@@ -78,7 +78,7 @@ class TestFun(TestBase):
@with_rw_repo('0.1.6')
def test_three_way_merge(self, rwrepo):
def mkfile(name, sha, executable=0):
- return (sha, S_IFREG | 0644 | executable*0111, name)
+ return (sha, S_IFREG | 0644 | executable * 0111, name)
def mkcommit(name, sha):
return (sha, S_IFDIR | S_IFLNK, name)
@@ -88,9 +88,9 @@ class TestFun(TestBase):
assert has_conflict == (len([e for e in entries if e.stage != 0]) > 0)
mktree = self.mktree
- shaa = "\1"*20
- shab = "\2"*20
- shac = "\3"*20
+ shaa = "\1" * 20
+ shab = "\2" * 20
+ shac = "\3" * 20
odb = rwrepo.odb
diff --git a/git/test/test_git.py b/git/test/test_git.py
index 06410c45..e8a4c6b3 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -5,15 +5,15 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
-from git.test.lib import ( TestBase,
+from git.test.lib import (TestBase,
patch,
raises,
assert_equal,
assert_true,
assert_match,
- fixture_path )
-from git import ( Git,
- GitCommandError )
+ fixture_path)
+from git import (Git,
+ GitCommandError)
class TestGit(TestBase):
@@ -52,7 +52,7 @@ class TestGit(TestBase):
assert_equal(["-s", "-t"], self.git.transform_kwargs(**{'s': True, 't': True}))
def test_it_executes_git_to_shell_and_returns_result(self):
- assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git","version"]))
+ assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))
def test_it_accepts_stdin(self):
filename = fixture_path("cat_file_blob")
@@ -71,13 +71,13 @@ class TestGit(TestBase):
# read header only
import subprocess as sp
hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167"
- g = self.git.cat_file(batch_check=True, istream=sp.PIPE,as_process=True)
+ g = self.git.cat_file(batch_check=True, istream=sp.PIPE, as_process=True)
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
g.stdin.flush()
obj_info = g.stdout.readline()
# read header + data
- g = self.git.cat_file(batch=True, istream=sp.PIPE,as_process=True)
+ g = self.git.cat_file(batch=True, istream=sp.PIPE, as_process=True)
g.stdin.write("b2339455342180c7cc1e9bba3e9f181f7baa5167\n")
g.stdin.flush()
obj_info_two = g.stdout.readline()
diff --git a/git/test/test_index.py b/git/test/test_index.py
index b902f4d5..f5c92099 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -63,8 +63,8 @@ class TestIndex(TestBase):
# test entry
last_val = None
entry = index.entries.itervalues().next()
- for attr in ("path","ctime","mtime","dev","inode","mode","uid",
- "gid","size","binsha", "hexsha", "stage"):
+ for attr in ("path", "ctime", "mtime", "dev", "inode", "mode", "uid",
+ "gid", "size", "binsha", "hexsha", "stage"):
val = getattr(entry, attr)
# END for each method
@@ -76,7 +76,7 @@ class TestIndex(TestBase):
# test stage
index_merge = IndexFile(self.rorepo, fixture_path("index_merge"))
assert len(index_merge.entries) == 106
- assert len(list(e for e in index_merge.entries.itervalues() if e.stage != 0 ))
+ assert len(list(e for e in index_merge.entries.itervalues() if e.stage != 0))
# write the data - it must match the original
tmpfile = tempfile.mktemp()
@@ -93,14 +93,14 @@ class TestIndex(TestBase):
num_blobs = 0
blist = list()
- for blob in tree.traverse(predicate = lambda e,d: e.type == "blob", branch_first=False):
- assert (blob.path,0) in index.entries
+ for blob in tree.traverse(predicate=lambda e, d: e.type == "blob", branch_first=False):
+ assert (blob.path, 0) in index.entries
blist.append(blob)
# END for each blob in tree
if len(blist) != len(index.entries):
iset = set(k[0] for k in index.entries.keys())
bset = set(b.path for b in blist)
- raise AssertionError( "CMP Failed: Missing entries in index: %s, missing in tree: %s" % (bset-iset, iset-bset) )
+ raise AssertionError("CMP Failed: Missing entries in index: %s, missing in tree: %s" % (bset - iset, iset - bset))
# END assertion message
@with_rw_repo('0.1.6')
@@ -127,7 +127,7 @@ class TestIndex(TestBase):
merge_required = lambda t: t[0] != 0
merge_blobs = list(three_way_index.iter_blobs(merge_required))
assert merge_blobs
- assert merge_blobs[0][0] in (1,2,3)
+ assert merge_blobs[0][0] in (1, 2, 3)
assert isinstance(merge_blobs[0][1], Blob)
# test BlobFilter
@@ -143,12 +143,12 @@ class TestIndex(TestBase):
assert unmerged_blob_map
# pick the first blob at the first stage we find and use it as resolved version
- three_way_index.resolve_blobs( l[0][1] for l in unmerged_blob_map.itervalues() )
+ three_way_index.resolve_blobs(l[0][1] for l in unmerged_blob_map.itervalues())
tree = three_way_index.write_tree()
assert isinstance(tree, Tree)
num_blobs = 0
- for blob in tree.traverse(predicate=lambda item,d: item.type == "blob"):
- assert (blob.path,0) in three_way_index.entries
+ for blob in tree.traverse(predicate=lambda item, d: item.type == "blob"):
+ assert (blob.path, 0) in three_way_index.entries
num_blobs += 1
# END for each blob
assert num_blobs == len(three_way_index.entries)
@@ -177,7 +177,7 @@ class TestIndex(TestBase):
# Add a change with a NULL sha that should conflict with next_commit. We
# pretend there was a change, but we do not even bother adding a proper
# sha for it ( which makes things faster of course )
- manifest_fake_entry = BaseIndexEntry((manifest_entry[0], "\0"*20, 0, manifest_entry[3]))
+ manifest_fake_entry = BaseIndexEntry((manifest_entry[0], "\0" * 20, 0, manifest_entry[3]))
# try write flag
self._assert_entries(rw_repo.index.add([manifest_fake_entry], write=False))
# add actually resolves the null-hex-sha for us as a feature, but we can
@@ -278,7 +278,7 @@ class TestIndex(TestBase):
assert not index.diff(None)
assert cur_branch == rw_repo.active_branch
assert cur_commit == rw_repo.head.commit
- fp = open(file_path,'rb')
+ fp = open(file_path, 'rb')
try:
assert fp.read() != new_data
finally:
@@ -397,7 +397,7 @@ class TestIndex(TestBase):
self.failUnlessRaises(TypeError, index.remove, [1])
# absolute path
- deleted_files = index.remove([os.path.join(rw_repo.working_tree_dir,"lib")], r=True)
+ deleted_files = index.remove([os.path.join(rw_repo.working_tree_dir, "lib")], r=True)
assert len(deleted_files) > 1
self.failUnlessRaises(ValueError, index.remove, ["/doesnt/exists"])
@@ -426,7 +426,7 @@ class TestIndex(TestBase):
# same index, multiple parents
commit_message = "Index with multiple parents\n commit with another line"
- commit_multi_parent = index.commit(commit_message,parent_commits=(commit_no_parents, new_commit))
+ commit_multi_parent = index.commit(commit_message, parent_commits=(commit_no_parents, new_commit))
assert commit_multi_parent.message == commit_message
assert len(commit_multi_parent.parents) == 2
assert commit_multi_parent.parents[0] == commit_no_parents
@@ -453,7 +453,7 @@ class TestIndex(TestBase):
assert len(entries) == 14
# same file
- entries = index.reset(new_commit).add([os.path.abspath(os.path.join('lib', 'git', 'head.py'))]*2, fprogress=self._fprogress_add)
+ entries = index.reset(new_commit).add([os.path.abspath(os.path.join('lib', 'git', 'head.py'))] * 2, fprogress=self._fprogress_add)
self._assert_entries(entries)
assert entries[0].mode & 0644 == 0644
# would fail, test is too primitive to handle this case
@@ -469,12 +469,12 @@ class TestIndex(TestBase):
entries = index.reset(new_commit).add([old_blob], fprogress=self._fprogress_add)
self._assert_entries(entries)
self._assert_fprogress(entries)
- assert index.entries[(old_blob.path,0)].hexsha == old_blob.hexsha and len(entries) == 1
+ assert index.entries[(old_blob.path, 0)].hexsha == old_blob.hexsha and len(entries) == 1
# mode 0 not allowed
null_hex_sha = Diff.NULL_HEX_SHA
null_bin_sha = "\0" * 20
- self.failUnlessRaises(ValueError, index.reset(new_commit).add, [BaseIndexEntry((0, null_bin_sha,0,"doesntmatter"))])
+ self.failUnlessRaises(ValueError, index.reset(new_commit).add, [BaseIndexEntry((0, null_bin_sha, 0, "doesntmatter"))])
# add new file
new_file_relapath = "my_new_file"
@@ -537,7 +537,7 @@ class TestIndex(TestBase):
if os.name == 'nt':
# simlinks should contain the link as text ( which is what a
# symlink actually is )
- open(fake_symlink_path,'rb').read() == link_target
+ open(fake_symlink_path, 'rb').read() == link_target
else:
assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE])
@@ -657,7 +657,7 @@ class TestIndex(TestBase):
H = self.rorepo.tree("25dca42bac17d511b7e2ebdd9d1d679e7626db5f")
M = self.rorepo.tree("e746f96bcc29238b79118123028ca170adc4ff0f")
- for args in ((B,), (B,H), (B,H,M)):
+ for args in ((B,), (B, H), (B, H, M)):
index = IndexFile.new(self.rorepo, *args)
assert isinstance(index, IndexFile)
# END for each arg tuple
diff --git a/git/test/test_reflog.py b/git/test/test_reflog.py
index 76cfd870..a68b25a3 100644
--- a/git/test/test_reflog.py
+++ b/git/test/test_reflog.py
@@ -52,14 +52,14 @@ class TestRefLog(TestBase):
# TODO: Try multiple corrupted ones !
pp = 'reflog_invalid_'
for suffix in ('oldsha', 'newsha', 'email', 'date', 'sep'):
- self.failUnlessRaises(ValueError, RefLog.from_file, fixture_path(pp+suffix))
+ self.failUnlessRaises(ValueError, RefLog.from_file, fixture_path(pp + suffix))
#END for each invalid file
# cannot write an uninitialized reflog
self.failUnlessRaises(ValueError, RefLog().write)
# test serialize and deserialize - results must match exactly
- binsha = chr(255)*20
+ binsha = chr(255) * 20
msg = "my reflog message"
cr = self.rorepo.config_reader()
for rlp in (rlp_head, rlp_master):
@@ -78,7 +78,7 @@ class TestRefLog(TestBase):
# append an entry
entry = RefLog.append_entry(cr, tfile, IndexObject.NULL_BIN_SHA, binsha, msg)
assert entry.oldhexsha == IndexObject.NULL_HEX_SHA
- assert entry.newhexsha == 'f'*40
+ assert entry.newhexsha == 'f' * 40
assert entry.message == msg
assert RefLog.from_file(tfile)[-1] == entry
diff --git a/git/test/test_refs.py b/git/test/test_refs.py
index fc58dafa..5658181d 100644
--- a/git/test/test_refs.py
+++ b/git/test/test_refs.py
@@ -18,7 +18,7 @@ class TestRefs(TestBase):
def test_from_path(self):
# should be able to create any reference directly
- for ref_type in ( Reference, Head, TagReference, RemoteReference ):
+ for ref_type in (Reference, Head, TagReference, RemoteReference):
for name in ('rela_name', 'path/rela_name'):
full_path = ref_type.to_full_path(name)
instance = ref_type.from_path(self.rorepo, full_path)
@@ -36,17 +36,17 @@ class TestRefs(TestBase):
for tag in self.rorepo.tags:
assert "refs/tags" in tag.path
assert tag.name
- assert isinstance( tag.commit, Commit )
+ assert isinstance(tag.commit, Commit)
if tag.tag is not None:
- tag_object_refs.append( tag )
+ tag_object_refs.append(tag)
tagobj = tag.tag
# have no dict
self.failUnlessRaises(AttributeError, setattr, tagobj, 'someattr', 1)
- assert isinstance( tagobj, TagObject )
+ assert isinstance(tagobj, TagObject)
assert tagobj.tag == tag.name
- assert isinstance( tagobj.tagger, Actor )
- assert isinstance( tagobj.tagged_date, int )
- assert isinstance( tagobj.tagger_tz_offset, int )
+ assert isinstance(tagobj.tagger, Actor)
+ assert isinstance(tagobj.tagged_date, int)
+ assert isinstance(tagobj.tagger_tz_offset, int)
assert tagobj.message
assert tag.object == tagobj
# can't assign the object
@@ -59,7 +59,7 @@ class TestRefs(TestBase):
def test_tags_author(self):
tag = self.rorepo.tags[0]
tagobj = tag.tag
- assert isinstance( tagobj.tagger, Actor )
+ assert isinstance(tagobj.tagger, Actor)
tagger_name = tagobj.tagger.name
assert tagger_name == 'Michael Trier'
@@ -77,7 +77,7 @@ class TestRefs(TestBase):
s.add(ref)
# END for each ref
assert len(s) == ref_count
- assert len(s|s) == ref_count
+ assert len(s | s) == ref_count
@with_rw_repo('HEAD', bare=False)
def test_heads(self, rwrepo):
@@ -127,19 +127,19 @@ class TestRefs(TestBase):
# head changes once again, cur_head doesn't change
head.set_reference(cur_head, 'reattach head')
- assert len(head.log()) == hlog_len+2
+ assert len(head.log()) == hlog_len + 2
assert len(cur_head.log()) == blog_len
# adjusting the head-ref also adjust the head, so both reflogs are
# altered
cur_head.set_commit(pcommit, 'changing commit')
- assert len(cur_head.log()) == blog_len+1
- assert len(head.log()) == hlog_len+3
+ assert len(cur_head.log()) == blog_len + 1
+ assert len(head.log()) == hlog_len + 3
# with automatic dereferencing
assert head.set_commit(cur_commit, 'change commit once again') is head
- assert len(head.log()) == hlog_len+4
- assert len(cur_head.log()) == blog_len+2
+ assert len(head.log()) == hlog_len + 4
+ assert len(cur_head.log()) == blog_len + 2
# a new branch has just a single entry
other_head = Head.create(rwrepo, 'mynewhead', pcommit, logmsg='new head created')
@@ -178,10 +178,10 @@ class TestRefs(TestBase):
# paths - make sure we have something to do
rw_repo.index.reset(old_head_commit.parents[0])
- cur_head.reset(cur_head, paths = "test")
- cur_head.reset(new_head_commit, paths = "lib")
+ cur_head.reset(cur_head, paths="test")
+ cur_head.reset(new_head_commit, paths="lib")
# hard resets with paths don't work, its all or nothing
- self.failUnlessRaises(GitCommandError, cur_head.reset, new_head_commit, working_tree=True, paths = "lib")
+ self.failUnlessRaises(GitCommandError, cur_head.reset, new_head_commit, working_tree=True, paths="lib")
# we can do a mixed reset, and then checkout from the index though
cur_head.reset(new_head_commit)
@@ -224,7 +224,7 @@ class TestRefs(TestBase):
commit = 'HEAD'
prev_head_commit = cur_head.commit
for count, new_name in enumerate(("my_new_head", "feature/feature1")):
- actual_commit = commit+"^"*count
+ actual_commit = commit + "^" * count
new_head = Head.create(rw_repo, new_name, actual_commit)
assert new_head.is_detached
assert cur_head.commit == prev_head_commit
@@ -265,7 +265,7 @@ class TestRefs(TestBase):
tag_name = "1.0.2"
light_tag = TagReference.create(rw_repo, tag_name)
self.failUnlessRaises(GitCommandError, TagReference.create, rw_repo, tag_name)
- light_tag = TagReference.create(rw_repo, tag_name, "HEAD~1", force = True)
+ light_tag = TagReference.create(rw_repo, tag_name, "HEAD~1", force=True)
assert isinstance(light_tag, TagReference)
assert light_tag.name == tag_name
assert light_tag.commit == cur_head.commit.parents[0]
@@ -362,11 +362,11 @@ class TestRefs(TestBase):
# checkout with force as we have a changed a file
# clear file
- open(new_head.commit.tree.blobs[-1].abspath,'w').close()
+ open(new_head.commit.tree.blobs[-1].abspath, 'w').close()
assert len(new_head.commit.diff(None))
# create a new branch that is likely to touch the file we changed
- far_away_head = rw_repo.create_head("far_head",'HEAD~100')
+ far_away_head = rw_repo.create_head("far_head", 'HEAD~100')
self.failUnlessRaises(GitCommandError, far_away_head.checkout)
assert active_branch == active_branch.checkout(force=True)
assert rw_repo.head.reference != far_away_head
@@ -441,7 +441,7 @@ class TestRefs(TestBase):
assert os.path.isfile(symbol_ref_abspath)
assert symref.commit == new_head.commit
- for name in ('absname','folder/rela_name'):
+ for name in ('absname', 'folder/rela_name'):
symref_new_name = symref.rename(name)
assert isinstance(symref_new_name, SymbolicReference)
assert name in symref_new_name.path
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index 19d029e5..638349ba 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -17,7 +17,7 @@ random.seed(0)
class TestRemoteProgress(RemoteProgress):
- __slots__ = ( "_seen_lines", "_stages_per_op", '_num_progress_messages' )
+ __slots__ = ("_seen_lines", "_stages_per_op", '_num_progress_messages')
def __init__(self):
super(TestRemoteProgress, self).__init__()
@@ -45,9 +45,9 @@ class TestRemoteProgress(RemoteProgress):
assert op_id in (self.COUNTING, self.COMPRESSING, self.WRITING)
self._stages_per_op.setdefault(op_id, 0)
- self._stages_per_op[ op_id ] = self._stages_per_op[ op_id ] | (op_code & self.STAGE_MASK)
+ self._stages_per_op[op_id] = self._stages_per_op[op_id] | (op_code & self.STAGE_MASK)
- if op_code & (self.WRITING|self.END) == (self.WRITING|self.END):
+ if op_code & (self.WRITING | self.END) == (self.WRITING | self.END):
assert message
# END check we get message
@@ -59,7 +59,7 @@ class TestRemoteProgress(RemoteProgress):
return
# sometimes objects are not compressed which is okay
- assert len(self._seen_ops) in (2,3)
+ assert len(self._seen_ops) in (2, 3)
assert self._stages_per_op
# must have seen all stages
@@ -86,7 +86,7 @@ class TestRemote(TestBase):
assert info.flags != 0
# END reference type flags handling
assert isinstance(info.ref, (SymbolicReference, Reference))
- if info.flags & (info.FORCED_UPDATE|info.FAST_FORWARD):
+ if info.flags & (info.FORCED_UPDATE | info.FAST_FORWARD):
assert isinstance(info.old_commit, Commit)
else:
assert info.old_commit is None
@@ -124,12 +124,12 @@ class TestRemote(TestBase):
#Create a file with a random name and random data and commit it to repo.
# Return the commited absolute file path
index = repo.index
- new_file = self._make_file(os.path.basename(tempfile.mktemp()),str(random.random()), repo)
+ new_file = self._make_file(os.path.basename(tempfile.mktemp()), str(random.random()), repo)
index.add([new_file])
index.commit("Committing %s" % new_file)
return new_file
- def _do_test_fetch(self,remote, rw_repo, remote_repo):
+ def _do_test_fetch(self, remote, rw_repo, remote_repo):
# specialized fetch testing to de-clutter the main test
self._do_test_fetch_info(rw_repo)
@@ -143,7 +143,7 @@ class TestRemote(TestBase):
# END fetch and check
def get_info(res, remote, name):
- return res["%s/%s"%(remote,name)]
+ return res["%s/%s" % (remote, name)]
# put remote head to master as it is garantueed to exist
remote_repo.head.reference = remote_repo.heads.master
@@ -159,7 +159,7 @@ class TestRemote(TestBase):
remote_commit = rhead.commit
rhead.reset("HEAD~2", index=False)
res = fetch_and_test(remote)
- mkey = "%s/%s"%(remote,'master')
+ mkey = "%s/%s" % (remote, 'master')
master_info = res[mkey]
assert master_info.flags & FetchInfo.FORCED_UPDATE and master_info.note is not None
@@ -192,7 +192,7 @@ class TestRemote(TestBase):
RemoteReference.delete(rw_repo, *stale_refs)
# test single branch fetch with refspec including target remote
- res = fetch_and_test(remote, refspec="master:refs/remotes/%s/master"%remote)
+ res = fetch_and_test(remote, refspec="master:refs/remotes/%s/master" % remote)
assert len(res) == 1 and get_info(res, remote, 'master')
# ... with respec and no target
@@ -230,7 +230,7 @@ class TestRemote(TestBase):
# must clone with a local path for the repo implementation not to freak out
# as it wants local paths only ( which I can understand )
other_repo = remote_repo.clone(other_repo_dir, shared=False)
- remote_repo_url = "git://localhost%s"%remote_repo.git_dir
+ remote_repo_url = "git://localhost%s" % remote_repo.git_dir
# put origin to git-url
other_origin = other_repo.remotes.origin
@@ -254,7 +254,7 @@ class TestRemote(TestBase):
shutil.rmtree(other_repo_dir)
# END test and cleanup
- def _assert_push_and_pull(self,remote, rw_repo, remote_repo):
+ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
# push our changes
lhead = rw_repo.head
lindex = rw_repo.index
@@ -429,7 +429,7 @@ class TestRemote(TestBase):
def test_creation_and_removal(self, bare_rw_repo):
new_name = "test_new_one"
arg_list = (new_name, "git@server:hello.git")
- remote = Remote.create(bare_rw_repo, *arg_list )
+ remote = Remote.create(bare_rw_repo, *arg_list)
assert remote.name == "test_new_one"
assert remote in bare_rw_repo.remotes
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 38c03b7a..86d355e6 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -52,7 +52,7 @@ class TestRepo(TestBase):
def test_heads_should_populate_head_data(self):
for head in self.rorepo.heads:
assert head.name
- assert isinstance(head.commit,Commit)
+ assert isinstance(head.commit, Commit)
# END for each head
assert isinstance(self.rorepo.heads.master, Head)
@@ -84,11 +84,11 @@ class TestRepo(TestBase):
assert_equal("Michael Trier", c.author.name)
assert_equal("mtrier@gmail.com", c.author.email)
assert_equal(1232829715, c.authored_date)
- assert_equal(5*3600, c.author_tz_offset)
+ assert_equal(5 * 3600, c.author_tz_offset)
assert_equal("Michael Trier", c.committer.name)
assert_equal("mtrier@gmail.com", c.committer.email)
assert_equal(1232829715, c.committed_date)
- assert_equal(5*3600, c.committer_tz_offset)
+ assert_equal(5 * 3600, c.committer_tz_offset)
assert_equal("Bumped version 0.1.6\n", c.message)
c = commits[1]
@@ -194,7 +194,7 @@ class TestRepo(TestBase):
def test_daemon_export(self):
orig_val = self.rorepo.daemon_export
self.rorepo.daemon_export = not orig_val
- assert self.rorepo.daemon_export == ( not orig_val )
+ assert self.rorepo.daemon_export == (not orig_val)
self.rorepo.daemon_export = orig_val
assert self.rorepo.daemon_export == orig_val
@@ -203,7 +203,7 @@ class TestRepo(TestBase):
# empty alternates
self.rorepo.alternates = []
assert self.rorepo.alternates == []
- alts = [ "other/location", "this/location" ]
+ alts = ["other/location", "this/location"]
self.rorepo.alternates = alts
assert alts == self.rorepo.alternates
self.rorepo.alternates = cur_alternates
@@ -220,9 +220,9 @@ class TestRepo(TestBase):
def test_is_dirty(self):
self.rorepo._bare = False
- for index in (0,1):
- for working_tree in (0,1):
- for untracked_files in (0,1):
+ for index in (0, 1):
+ for working_tree in (0, 1):
+ for untracked_files in (0, 1):
assert self.rorepo.is_dirty(index, working_tree, untracked_files) in (True, False)
# END untracked files
# END working tree
@@ -250,9 +250,9 @@ class TestRepo(TestBase):
@patch.object(Git, '_call_process')
def test_should_display_blame_information(self, git):
git.return_value = fixture('blame')
- b = self.rorepo.blame( 'master', 'lib/git.py')
+ b = self.rorepo.blame('master', 'lib/git.py')
assert_equal(13, len(b))
- assert_equal( 2, len(b[0]) )
+ assert_equal(2, len(b[0]))
# assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b))
assert_equal(hash(b[0][0]), hash(b[9][0]))
c = b[0][0]
@@ -270,9 +270,9 @@ class TestRepo(TestBase):
# test the 'lines per commit' entries
tlist = b[0][1]
- assert_true( tlist )
- assert_true( isinstance( tlist[0], basestring ) )
- assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug
+ assert_true(tlist)
+ assert_true(isinstance(tlist[0], basestring))
+ assert_true(len(tlist) < sum(len(t) for t in tlist)) # test for single-char bug
def test_blame_real(self):
c = 0
@@ -285,12 +285,12 @@ class TestRepo(TestBase):
def test_untracked_files(self):
base = self.rorepo.working_tree_dir
- files = ( join_path_native(base, "__test_myfile"),
- join_path_native(base, "__test_other_file") )
+ files = (join_path_native(base, "__test_myfile"),
+ join_path_native(base, "__test_other_file"))
num_recently_untracked = 0
try:
for fpath in files:
- fd = open(fpath,"wb")
+ fd = open(fpath, "wb")
fd.close()
# END for each filename
untracked_files = self.rorepo.untracked_files
@@ -356,7 +356,7 @@ class TestRepo(TestBase):
# full size
# size is without terminating newline
def mkfull():
- return Git.CatFileContentStream(len(d)-1, StringIO(d))
+ return Git.CatFileContentStream(len(d) - 1, StringIO(d))
ts = 5
@@ -378,7 +378,7 @@ class TestRepo(TestBase):
s = mktiny()
lines = s.readlines()
assert len(lines) == 1 and lines[0] == l1p
- assert s._stream.tell() == ts+1
+ assert s._stream.tell() == ts + 1
# readline no limit
s = mkfull()
@@ -397,7 +397,7 @@ class TestRepo(TestBase):
s = mktiny()
assert s.readline() == l1p
assert s.readline() == ''
- assert s._stream.tell() == ts+1
+ assert s._stream.tell() == ts + 1
# read no limit
s = mkfull()
@@ -416,7 +416,7 @@ class TestRepo(TestBase):
assert s.read(2) == l1[:2]
assert s._stream.tell() == 2
assert s.read() == l1[2:ts]
- assert s._stream.tell() == ts+1
+ assert s._stream.tell() == ts + 1
def _assert_rev_parse_types(self, name, rev_obj):
rev_parse = self.rorepo.rev_parse
@@ -457,7 +457,7 @@ class TestRepo(TestBase):
# END get given amount of commits
for pn in range(11):
- rev = name + "~%i" % (pn+1)
+ rev = name + "~%i" % (pn + 1)
obj2 = rev_parse(rev)
assert obj2 == history[pn]
self._assert_rev_parse_types(rev, obj2)
@@ -471,7 +471,7 @@ class TestRepo(TestBase):
# parent with number
for pn, parent in enumerate(obj.parents):
- rev = name + "^%i" % (pn+1)
+ rev = name + "^%i" % (pn + 1)
assert rev_parse(rev) == parent
self._assert_rev_parse_types(rev, parent)
# END for each parent
@@ -496,7 +496,7 @@ class TestRepo(TestBase):
for ref in Reference.iter_items(self.rorepo):
path_tokens = ref.path.split("/")
for pt in range(len(path_tokens)):
- path_section = '/'.join(path_tokens[-(pt+1):])
+ path_section = '/'.join(path_tokens[-(pt + 1):])
try:
obj = self._assert_rev_parse(path_section)
assert obj.type == ref.object.type
@@ -521,7 +521,7 @@ class TestRepo(TestBase):
# multiple tree types result in the same tree: HEAD^{tree}^{tree}:CHANGES
rev = '0.1.4^{tree}^{tree}'
assert rev_parse(rev) == tag.object.tree
- assert rev_parse(rev+':CHANGES') == tag.object.tree['CHANGES']
+ assert rev_parse(rev + ':CHANGES') == tag.object.tree['CHANGES']
# try to get parents from first revision - it should fail as no such revision
# exists
@@ -529,8 +529,8 @@ class TestRepo(TestBase):
commit = rev_parse(first_rev)
assert len(commit.parents) == 0
assert commit.hexsha == first_rev
- self.failUnlessRaises(BadObject, rev_parse, first_rev+"~")
- self.failUnlessRaises(BadObject, rev_parse, first_rev+"^")
+ self.failUnlessRaises(BadObject, rev_parse, first_rev + "~")
+ self.failUnlessRaises(BadObject, rev_parse, first_rev + "^")
# short SHA1
commit2 = rev_parse(first_rev[:20])
@@ -550,7 +550,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)]).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
@@ -576,8 +576,8 @@ class TestRepo(TestBase):
refspec = '%s@{0}' % head.ref.name
assert rev_parse(refspec) == head.ref.commit
# all additional specs work as well
- assert rev_parse(refspec+"^{tree}") == head.commit.tree
- assert rev_parse(refspec+":CHANGES").type == 'blob'
+ assert rev_parse(refspec + "^{tree}") == head.commit.tree
+ assert rev_parse(refspec + ":CHANGES").type == 'blob'
#END operate on non-detached head
# the last position
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index 0cf620c1..b657b25e 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -43,7 +43,7 @@ class TestSubmodule(TestBase):
def _do_base_tests(self, rwrepo):
"""Perform all tests in the given repository, it may be bare or nonbare"""
# manual instantiation
- smm = Submodule(rwrepo, "\0"*20)
+ smm = Submodule(rwrepo, "\0" * 20)
# name needs to be set in advance
self.failUnlessRaises(AttributeError, getattr, smm, 'name')
@@ -107,7 +107,7 @@ class TestSubmodule(TestBase):
prev_parent_commit = smold.parent_commit
self.failUnlessRaises(ValueError, smold.set_parent_commit, self.k_subm_current)
# the sha is properly updated
- smold.set_parent_commit(self.k_subm_changed+"~1")
+ smold.set_parent_commit(self.k_subm_changed + "~1")
assert smold.binsha != sm.binsha
# raises if the sm didn't exist in new parent - it keeps its
@@ -130,7 +130,7 @@ class TestSubmodule(TestBase):
# currently there is only one submodule
assert len(list(rwrepo.iter_submodules())) == 1
- assert sm.binsha != "\0"*20
+ assert sm.binsha != "\0" * 20
# TEST ADD
###########
@@ -303,7 +303,7 @@ class TestSubmodule(TestBase):
# add a simple remote repo - trailing slashes are no problem
smid = "newsub"
osmid = "othersub"
- nsm = Submodule.add(rwrepo, smid, sm_repopath, new_smclone_path+"/", None, no_checkout=True)
+ nsm = Submodule.add(rwrepo, smid, sm_repopath, new_smclone_path + "/", None, no_checkout=True)
assert nsm.name == smid
assert nsm.module_exists()
assert nsm.exists()
diff --git a/git/test/test_tree.py b/git/test/test_tree.py
index 7edae577..e3743c2d 100644
--- a/git/test/test_tree.py
+++ b/git/test/test_tree.py
@@ -59,7 +59,7 @@ class TestTree(TestBase):
assert len(testtree) == cur_count
# fails with a different sha - name exists
- hexsha = "1"*40
+ hexsha = "1" * 40
self.failUnlessRaises(ValueError, mod.add, hexsha, tree.mode, name)
# force it - replace existing one
@@ -113,18 +113,18 @@ class TestTree(TestBase):
assert len(list(root)) == len(list(root.traverse(depth=1)))
# only choose trees
- trees_only = lambda i,d: i.type == "tree"
- trees = list(root.traverse(predicate = trees_only))
- assert len(trees) == len(list( i for i in root.traverse() if trees_only(i,0) ))
+ trees_only = lambda i, d: i.type == "tree"
+ trees = list(root.traverse(predicate=trees_only))
+ assert len(trees) == len(list(i for i in root.traverse() if trees_only(i, 0)))
# test prune
- lib_folder = lambda t,d: t.path == "lib"
- pruned_trees = list(root.traverse(predicate = trees_only,prune = lib_folder))
+ lib_folder = lambda t, d: t.path == "lib"
+ pruned_trees = list(root.traverse(predicate=trees_only, prune=lib_folder))
assert len(pruned_trees) < len(trees)
# trees and blobs
- assert len(set(trees)|set(root.trees)) == len(trees)
- assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len( root.blobs )
+ assert len(set(trees) | set(root.trees)) == len(trees)
+ assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len(root.blobs)
subitem = trees[0][0]
assert "/" in subitem.path
assert subitem.name == os.path.basename(subitem.path)
@@ -138,6 +138,6 @@ class TestTree(TestBase):
# END check for slash
# slashes in paths are supported as well
- assert root[item.path] == item == root/item.path
+ assert root[item.path] == item == root / item.path
# END for each item
assert found_slash
diff --git a/git/test/test_util.py b/git/test/test_util.py
index ea62425b..63842d19 100644
--- a/git/test/test_util.py
+++ b/git/test/test_util.py
@@ -30,9 +30,9 @@ class TestUtils(TestBase):
def setup(self):
self.testdict = {
- "string": "42",
- "int": 42,
- "array": [ 42 ],
+ "string": "42",
+ "int": 42,
+ "array": [42],
}
def test_it_should_dashify(self):