From 0c86307eb53dcea7942e11be0710d62eda54a48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid.ibp@gmail.com> Date: Sun, 26 May 2013 14:39:12 +0200 Subject: [PATCH] Coding style: Silent pep8 --- .pep8 | 2 +- pygit2/repository.py | 3 +-- test/test_config.py | 39 ++++++++++++++++++++++----------------- test/test_diff.py | 3 ++- test/test_note.py | 4 ++-- test/test_oid.py | 1 + test/test_refs.py | 4 ++-- test/test_remote.py | 1 + test/test_revwalk.py | 19 +++++++------------ test/test_treebuilder.py | 1 + 10 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.pep8 b/.pep8 index 92c073b..a5a00a5 100644 --- a/.pep8 +++ b/.pep8 @@ -1,3 +1,3 @@ [pep8] exclude = .git,build,docs -ignore = +ignore = E303 diff --git a/pygit2/repository.py b/pygit2/repository.py index ba40b2a..d235b8d 100644 --- a/pygit2/repository.py +++ b/pygit2/repository.py @@ -83,8 +83,7 @@ class Repository(_Repository): type(target) is Oid or ( all(c in hexdigits for c in target) - and GIT_OID_MINPREFIXLEN <= len(target) <= GIT_OID_HEXSZ) - ) + and GIT_OID_MINPREFIXLEN <= len(target) <= GIT_OID_HEXSZ)) if direct: return self.create_reference_direct(name, target, force) diff --git a/test/test_config.py b/test/test_config.py index 9c7e13d..a8afe86 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -30,22 +30,24 @@ import os import unittest -import pygit2 +from pygit2 import Config from . import utils -config_filename = "test_config" +CONFIG_FILENAME = "test_config" + def foreach_test_wrapper(key, name, lst): lst[key] = name return 0 foreach_test_wrapper.__test__ = False + class ConfigTest(utils.RepoTestCase): def tearDown(self): try: - os.remove(config_filename) + os.remove(CONFIG_FILENAME) except OSError: pass @@ -54,40 +56,43 @@ class ConfigTest(utils.RepoTestCase): def test_global_config(self): try: - self.assertNotEqual(None, pygit2.Config.get_global_config()) - except IOError: # there is no user config + self.assertNotEqual(None, Config.get_global_config()) + except IOError: + # There is no user config pass def test_system_config(self): try: - self.assertNotEqual(None, pygit2.Config.get_system_config()) - except IOError: # there is no system config + self.assertNotEqual(None, Config.get_system_config()) + except IOError: + # There is no system config pass def test_new(self): - open(config_filename, 'w').close() # touch file - config_write = pygit2.Config(config_filename) + # Touch file + open(CONFIG_FILENAME, 'w').close() + config_write = Config(CONFIG_FILENAME) self.assertNotEqual(config_write, None) config_write['core.bare'] = False config_write['core.editor'] = 'ed' - config_read = pygit2.Config(config_filename) + config_read = Config(CONFIG_FILENAME) self.assertTrue('core.bare' in config_read) self.assertFalse(config_read['core.bare']) self.assertTrue('core.editor' in config_read) self.assertEqual(config_read['core.editor'], 'ed') def test_add(self): - config = pygit2.Config() + config = Config() - new_file = open(config_filename, "w") + new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = true\n") new_file.write("[something \"other\"]\n\there = false") new_file.close() - config.add_file(config_filename, 0) + config.add_file(CONFIG_FILENAME, 0) self.assertTrue('this.that' in config) self.assertTrue(config['this.that']) self.assertTrue('something.other.here' in config) @@ -110,11 +115,11 @@ class ConfigTest(utils.RepoTestCase): self.assertTrue('core.repositoryformatversion' in config) self.assertEqual(config['core.repositoryformatversion'], 0) - new_file = open(config_filename, "w") + new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = foobar\n\tthat = foobeer\n") new_file.close() - config.add_file(config_filename, 0) + config.add_file(CONFIG_FILENAME, 0) self.assertTrue('this.that' in config) self.assertEqual(len(config.get_multivar('this.that')), 2) l = config.get_multivar('this.that', 'bar') @@ -149,11 +154,11 @@ class ConfigTest(utils.RepoTestCase): del config['core.dummy3'] self.assertFalse('core.dummy3' in config) - new_file = open(config_filename, "w") + new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = foobar\n\tthat = foobeer\n") new_file.close() - config.add_file(config_filename, 5) + config.add_file(CONFIG_FILENAME, 5) self.assertTrue('this.that' in config) l = config.get_multivar('this.that', 'foo.*') self.assertEqual(len(l), 2) diff --git a/test/test_diff.py b/test/test_diff.py index 09ce99a..697b8be 100644 --- a/test/test_diff.py +++ b/test/test_diff.py @@ -100,6 +100,7 @@ HUNK_EXPECTED = """- a contents 2 + a contents """ + class DiffDirtyTest(utils.DirtyRepoTestCase): def test_diff_empty_index(self): repo = self.repo @@ -198,7 +199,7 @@ class DiffTest(utils.BareRepoTestCase): self.assertAll(lambda x: '+' == x, get_context_for_lines(diff_swaped)) def test_diff_revparse(self): - diff = self.repo.diff('HEAD','HEAD~6') + diff = self.repo.diff('HEAD', 'HEAD~6') self.assertEqual(type(diff), pygit2.Diff) def test_diff_tree_opts(self): diff --git a/test/test_note.py b/test/test_note.py index d6ea11f..a0ef443 100644 --- a/test/test_note.py +++ b/test/test_note.py @@ -40,8 +40,8 @@ NOTES = [ ('ab533997b80705767be3dae8cbb06a0740809f79', 'First Note - HEAD\n', '784855caf26449a1914d2cf62d12b9374d76ae78'), ('d879714d880671ed84f8aaed8b27fca23ba01f27', 'Second Note - HEAD~1\n', - 'f5e5aa4e36ab0fe62ee1ccc6eb8f79b866863b87') - ] + 'f5e5aa4e36ab0fe62ee1ccc6eb8f79b866863b87')] + class NotesTest(utils.BareRepoTestCase): diff --git a/test/test_oid.py b/test/test_oid.py index c303ce6..e631399 100644 --- a/test/test_oid.py +++ b/test/test_oid.py @@ -44,6 +44,7 @@ from . import utils HEX = "15b648aec6ed045b5ca6f57f8b7831a8b4757298" RAW = unhexlify(HEX.encode('ascii')) + class OidTest(utils.BareRepoTestCase): def test_raw(self): diff --git a/test/test_refs.py b/test/test_refs.py index ecad5f6..3b0a660 100644 --- a/test/test_refs.py +++ b/test/test_refs.py @@ -179,8 +179,8 @@ class ReferencesTest(utils.RepoTestCase): 'refs/tags/version1', LAST_COMMIT) # try to create existing reference with force - reference = self.repo.create_reference('refs/tags/version1', - LAST_COMMIT, force=True) + reference = self.repo.create_reference('refs/tags/version1', + LAST_COMMIT, force=True) self.assertEqual(reference.target.hex, LAST_COMMIT) diff --git a/test/test_remote.py b/test/test_remote.py index 279c811..d0ddebc 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -39,6 +39,7 @@ REMOTE_FETCHSPEC_DST = 'refs/remotes/origin/*' REMOTE_REPO_OBJECTS = 30 REMOTE_REPO_BYTES = 2758 + class RepositoryTest(utils.RepoTestCase): def test_remote_create(self): name = 'upstream' diff --git a/test/test_revwalk.py b/test/test_revwalk.py index dd97b82..119f222 100644 --- a/test/test_revwalk.py +++ b/test/test_revwalk.py @@ -69,13 +69,11 @@ class WalkerTest(utils.RepoTestCase): def test_walk(self): walker = self.repo.walk(log[0], GIT_SORT_TIME) - out = [ x.hex for x in walker ] - self.assertEqual(out, log) + self.assertEqual([x.hex for x in walker], log) def test_reverse(self): walker = self.repo.walk(log[0], GIT_SORT_TIME | GIT_SORT_REVERSE) - out = [ x.hex for x in walker ] - self.assertEqual(out, list(reversed(log))) + self.assertEqual([x.hex for x in walker], list(reversed(log))) def test_hide(self): walker = self.repo.walk(log[0], GIT_SORT_TIME) @@ -90,23 +88,20 @@ class WalkerTest(utils.RepoTestCase): def test_reset(self): walker = self.repo.walk(log[0], GIT_SORT_TIME) walker.reset() - out = [ x.hex for x in walker ] - self.assertEqual(out, []) + self.assertEqual([x.hex for x in walker], []) def test_push(self): walker = self.repo.walk(log[-1], GIT_SORT_TIME) - out = [ x.hex for x in walker ] - self.assertEqual(out, log[-1:]) + self.assertEqual([x.hex for x in walker], log[-1:]) walker.reset() walker.push(log[0]) - out = [ x.hex for x in walker ] - self.assertEqual(out, log) + self.assertEqual([x.hex for x in walker], log) def test_sort(self): walker = self.repo.walk(log[0], GIT_SORT_TIME) walker.sort(GIT_SORT_TIME | GIT_SORT_REVERSE) - out = [ x.hex for x in walker ] - self.assertEqual(out, list(reversed(log))) + self.assertEqual([x.hex for x in walker], list(reversed(log))) + if __name__ == '__main__': unittest.main() diff --git a/test/test_treebuilder.py b/test/test_treebuilder.py index 51e7a10..6b2d99a 100644 --- a/test/test_treebuilder.py +++ b/test/test_treebuilder.py @@ -36,6 +36,7 @@ from . import utils TREE_SHA = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12' + class TreeBuilderTest(utils.BareRepoTestCase): def test_new_empty_treebuilder(self):