Coding style: Silent pep8
This commit is contained in:
parent
19c9a895d5
commit
0c86307eb5
2
.pep8
2
.pep8
@ -1,3 +1,3 @@
|
||||
[pep8]
|
||||
exclude = .git,build,docs
|
||||
ignore =
|
||||
ignore = E303
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
@ -40,8 +40,8 @@ NOTES = [
|
||||
('ab533997b80705767be3dae8cbb06a0740809f79', 'First Note - HEAD\n',
|
||||
'784855caf26449a1914d2cf62d12b9374d76ae78'),
|
||||
('d879714d880671ed84f8aaed8b27fca23ba01f27', 'Second Note - HEAD~1\n',
|
||||
'f5e5aa4e36ab0fe62ee1ccc6eb8f79b866863b87')
|
||||
]
|
||||
'f5e5aa4e36ab0fe62ee1ccc6eb8f79b866863b87')]
|
||||
|
||||
|
||||
class NotesTest(utils.BareRepoTestCase):
|
||||
|
||||
|
@ -44,6 +44,7 @@ from . import utils
|
||||
HEX = "15b648aec6ed045b5ca6f57f8b7831a8b4757298"
|
||||
RAW = unhexlify(HEX.encode('ascii'))
|
||||
|
||||
|
||||
class OidTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_raw(self):
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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()
|
||||
|
@ -36,6 +36,7 @@ from . import utils
|
||||
|
||||
TREE_SHA = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12'
|
||||
|
||||
|
||||
class TreeBuilderTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_new_empty_treebuilder(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user