From f5d11b750ecc982541d1f936488248f0b42d75d3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:15:50 +0100 Subject: pep8 linting (whitespaces) W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file --- git/test/test_commit.py | 86 ++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'git/test/test_commit.py') diff --git a/git/test/test_commit.py b/git/test/test_commit.py index f536470f..d6ad3a62 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -22,11 +22,11 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False) :param print_performance_info: if True, we will show how fast we are""" ns = 0 # num serializations nds = 0 # num deserializations - + st = time.time() for cm in rwrepo.commit(commit_id).traverse(): nds += 1 - + # assert that we deserialize commits correctly, hence we get the same # sha on serialization stream = StringIO() @@ -34,37 +34,37 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False) ns += 1 streamlen = stream.tell() stream.seek(0) - + istream = rwrepo.odb.store(IStream(Commit.type, streamlen, stream)) assert istream.hexsha == cm.hexsha - + nc = Commit(rwrepo, Commit.NULL_BIN_SHA, cm.tree, cm.author, cm.authored_date, cm.author_tz_offset, cm.committer, cm.committed_date, cm.committer_tz_offset, cm.message, cm.parents, cm.encoding) - + assert nc.parents == cm.parents stream = StringIO() nc._serialize(stream) ns += 1 streamlen = stream.tell() stream.seek(0) - + # reuse istream istream.size = streamlen istream.stream = stream istream.binsha = None nc.binsha = rwrepo.odb.store(istream).binsha - + # if it worked, we have exactly the same contents ! assert nc.hexsha == cm.hexsha # END check commits 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) # END handle performance info - + class TestCommit(TestBase): @@ -86,7 +86,7 @@ class TestCommit(TestBase): def test_stats(self): commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats - + def check_entries(d): assert isinstance(d, dict) for key in ("insertions", "deletions", "lines"): @@ -94,14 +94,14 @@ class TestCommit(TestBase): # END assertion helper assert stats.files assert stats.total - + check_entries(stats.total) assert "files" in stats.total - + for filepath, d in stats.files.items(): check_entries(d) # END for each stated file - + # assure data is parsed properly michael = Actor._from_string("Michael Trier ") assert commit.author == michael @@ -111,7 +111,7 @@ class TestCommit(TestBase): assert commit.author_tz_offset == 14400, commit.author_tz_offset assert commit.committer_tz_offset == 14400, commit.committer_tz_offset assert commit.message == "initial project\n" - + def test_unicode_actor(self): # assure we can parse unicode actors correctly name = "Üäöß ÄußÉ".decode("utf-8") @@ -119,7 +119,7 @@ class TestCommit(TestBase): special = Actor._from_string(u"%s " % name) assert special.name == name assert isinstance(special.name, unicode) - + def test_traversal(self): start = self.rorepo.commit("a4d06724202afccd2b5c54f81bcf2bf26dea7fff") first = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781") @@ -127,65 +127,65 @@ class TestCommit(TestBase): p1 = start.parents[1] p00 = p0.parents[0] p10 = p1.parents[0] - + # basic branch first, depth first dfirst = start.traverse(branch_first=False) bfirst = start.traverse(branch_first=True) assert dfirst.next() == p0 assert dfirst.next() == p00 - + assert bfirst.next() == p0 assert bfirst.next() == p1 assert bfirst.next() == p00 assert bfirst.next() == p10 - + # at some point, both iterations should stop assert list(bfirst)[-1] == first stoptraverse = self.rorepo.commit("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d").traverse(as_edge=True) l = list(stoptraverse) assert len(l[0]) == 2 - + # ignore self assert start.traverse(ignore_self=False).next() == start - + # depth 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) - + # parents of the first commit should be empty ( as the only parent has a null # sha ) assert len(first.parents) == 0 - + def test_iteration(self): # we can iterate commits all_commits = Commit.list_items(self.rorepo, self.rorepo.head) assert all_commits assert all_commits == list(self.rorepo.iter_commits()) - + # this includes merge commits mcomit = self.rorepo.commit('d884adc80c80300b4cc05321494713904ef1df2d') assert mcomit in all_commits - + # we can limit the result to paths ltd_commits = list(self.rorepo.iter_commits(paths='CHANGES')) assert ltd_commits and len(ltd_commits) < len(all_commits) - + # show commits of multiple paths, resulting in a union of commits less_ltd_commits = list(Commit.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS'))) assert len(ltd_commits) < len(less_ltd_commits) - + def test_iter_items(self): # pretty not allowed self.failUnlessRaises(ValueError, Commit.iter_items, self.rorepo, 'master', pretty="raw") - + def test_rev_list_bisect_all(self): """ 'git rev-list --bisect-all' returns additional information @@ -207,7 +207,7 @@ class TestCommit(TestBase): def test_count(self): 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) @@ -225,7 +225,7 @@ class TestCommit(TestBase): commit3 = Commit(self.rorepo, "\1"*20) assert_equal(commit1, commit2) assert_not_equal(commit2, commit3) - + def test_iter_parents(self): # should return all but ourselves, even if skip is defined c = self.rorepo.commit('0.1.5') @@ -235,39 +235,39 @@ class TestCommit(TestBase): assert first_parent != c assert first_parent == c.parents[0] # END for each - + def test_base(self): name_rev = self.rorepo.head.commit.name_rev assert isinstance(name_rev, basestring) - + @with_rw_repo('HEAD', bare=True) def test_serialization(self, rwrepo): # create all commits of our repo assert_commit_serialization(rwrepo, '0.1.6') - + def test_serialization_unicode_support(self): assert Commit.default_encoding.lower() == 'utf-8' - + # create a commit with unicode in the message, and the author's name # Verify its serialization and deserialization cmt = self.rorepo.commit('0.1.6') assert isinstance(cmt.message, unicode) # it automatically decodes it as such assert isinstance(cmt.author.name, unicode) # same here - + cmt.message = "üäêèß".decode("utf-8") assert len(cmt.message) == 5 - + cmt.author.name = "äüß".decode("utf-8") assert len(cmt.author.name) == 3 - + cstream = StringIO() cmt._serialize(cstream) cstream.seek(0) assert len(cstream.getvalue()) - + ncmt = Commit(self.rorepo, cmt.binsha) ncmt._deserialize(cstream) - + assert cmt.author.name == ncmt.author.name assert cmt.message == ncmt.message # actually, it can't be printed in a shell as repr wants to have ascii only -- cgit v1.2.3 From be34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:51:04 +0100 Subject: pep8 linting (blank lines expectations) E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n) --- git/test/test_commit.py | 1 - 1 file changed, 1 deletion(-) (limited to 'git/test/test_commit.py') diff --git a/git/test/test_commit.py b/git/test/test_commit.py index d6ad3a62..d6e13762 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -82,7 +82,6 @@ class TestCommit(TestBase): assert isinstance(commit.author_tz_offset, int) and isinstance(commit.committer_tz_offset, int) assert commit.message == "Added missing information to docstrings of commit and stats module\n" - def test_stats(self): commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats -- cgit v1.2.3 From 614907b7445e2ed8584c1c37df7e466e3b56170f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:56:53 +0100 Subject: 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 --- git/test/test_commit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git/test/test_commit.py') 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) -- cgit v1.2.3 From bed3b0989730cdc3f513884325f1447eb378aaee Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:06:57 +0100 Subject: pep8 linting (double spaces before comment) E261 at least two spaces before inline comment --- git/test/test_commit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/test/test_commit.py') diff --git a/git/test/test_commit.py b/git/test/test_commit.py index 7bb019f4..e211f75b 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -73,7 +73,7 @@ class TestCommit(TestBase): commit = self.rorepo.commit('2454ae89983a4496a445ce347d7a41c0bb0ea7ae') # commits have no dict self.failUnlessRaises(AttributeError, setattr, commit, 'someattr', 1) - commit.author # bake + commit.author # bake assert_equal("Sebastian Thiel", commit.author.name) assert_equal("byronimo@gmail.com", commit.author.email) @@ -251,7 +251,7 @@ class TestCommit(TestBase): # Verify its serialization and deserialization cmt = self.rorepo.commit('0.1.6') assert isinstance(cmt.message, unicode) # it automatically decodes it as such - assert isinstance(cmt.author.name, unicode) # same here + assert isinstance(cmt.author.name, unicode) # same here cmt.message = "üäêèß".decode("utf-8") assert len(cmt.message) == 5 -- cgit v1.2.3 From c8e70749887370a99adeda972cc3503397b5f9a7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:09:47 +0100 Subject: pep8 linting (trailing whitespace) W291 trailing whitespace --- git/test/test_commit.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'git/test/test_commit.py') diff --git a/git/test/test_commit.py b/git/test/test_commit.py index e211f75b..6cd892f0 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -17,7 +17,7 @@ import re def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False): - """traverse all commits in the history of commit identified by commit_id and check + """traverse all commits in the history of commit identified by commit_id and check if the serialization works. :param print_performance_info: if True, we will show how fast we are""" ns = 0 # num serializations @@ -27,7 +27,7 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False) for cm in rwrepo.commit(commit_id).traverse(): nds += 1 - # assert that we deserialize commits correctly, hence we get the same + # assert that we deserialize commits correctly, hence we get the same # sha on serialization stream = StringIO() cm._serialize(stream) @@ -39,8 +39,8 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False) assert istream.hexsha == cm.hexsha nc = Commit(rwrepo, Commit.NULL_BIN_SHA, cm.tree, - cm.author, cm.authored_date, cm.author_tz_offset, - cm.committer, cm.committed_date, cm.committer_tz_offset, + cm.author, cm.authored_date, cm.author_tz_offset, + cm.committer, cm.committed_date, cm.committer_tz_offset, cm.message, cm.parents, cm.encoding) assert nc.parents == cm.parents @@ -90,11 +90,11 @@ class TestCommit(TestBase): assert isinstance(d, dict) for key in ("insertions", "deletions", "lines"): assert key in d - # END assertion helper - assert stats.files + # END assertion helper + assert stats.files assert stats.total - check_entries(stats.total) + check_entries(stats.total) assert "files" in stats.total for filepath, d in stats.files.items(): @@ -147,7 +147,7 @@ class TestCommit(TestBase): # ignore self assert start.traverse(ignore_self=False).next() == start - # depth + # depth assert len(list(start.traverse(ignore_self=False, depth=0))) == 1 # prune @@ -159,7 +159,7 @@ class TestCommit(TestBase): # traversal should stop when the beginning is reached self.failUnlessRaises(StopIteration, first.traverse().next) - # parents of the first commit should be empty ( as the only parent has a null + # parents of the first commit should be empty ( as the only parent has a null # sha ) assert len(first.parents) == 0 @@ -233,7 +233,7 @@ class TestCommit(TestBase): first_parent = piter.next() assert first_parent != c assert first_parent == c.parents[0] - # END for each + # END for each def test_base(self): name_rev = self.rorepo.head.commit.name_rev -- cgit v1.2.3