Fixing coding style with the help of pep8 (wip)
This commit is contained in:
		
							
								
								
									
										12
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								setup.py
									
									
									
									
									
								
							| @@ -31,13 +31,15 @@ | ||||
| from __future__ import print_function | ||||
|  | ||||
| import codecs | ||||
| import os | ||||
| from subprocess import Popen, PIPE | ||||
| import sys | ||||
| from distutils.core import setup, Extension, Command | ||||
| from distutils.command.build import build | ||||
| from distutils.command.sdist import sdist | ||||
| from distutils import log | ||||
| import os | ||||
| import shlex | ||||
| from subprocess import Popen, PIPE | ||||
| import sys | ||||
| import unittest | ||||
|  | ||||
| # Read version from local pygit2/version.py without pulling in | ||||
| # pygit2/__init__.py | ||||
| @@ -85,11 +87,9 @@ class TestCommand(Command): | ||||
|     def run(self): | ||||
|         self.run_command('build') | ||||
|         bld = self.distribution.get_command_obj('build') | ||||
|         #Add build_lib in to sys.path so that unittest can found DLLs and libs | ||||
|         # Add build_lib in to sys.path so that unittest can found DLLs and libs | ||||
|         sys.path = [os.path.abspath(bld.build_lib)] + sys.path | ||||
|  | ||||
|         import shlex | ||||
|         import unittest | ||||
|         test_argv0 = [sys.argv[0] + ' test --args='] | ||||
|         # For transfering args to unittest, we have to split args by ourself, | ||||
|         # so that command like: | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
|  | ||||
| from __future__ import absolute_import | ||||
| from __future__ import unicode_literals | ||||
| import os | ||||
| from os.path import dirname, join | ||||
| import unittest | ||||
|  | ||||
| import pygit2 | ||||
| @@ -91,14 +91,14 @@ class BlobTest(utils.RepoTestCase): | ||||
|         self.assertEqual(len(BLOB_FILE_CONTENT), blob.size) | ||||
|         self.assertEqual(BLOB_FILE_CONTENT, blob.read_raw()) | ||||
|  | ||||
|     def test_create_blob_outside_workdir(self): | ||||
|  | ||||
|         path = os.path.join(os.path.dirname(__file__), 'data', self.repo_dir + '.tar') | ||||
|     def test_create_blob_outside_workdir(self): | ||||
|         path = join(dirname(__file__), 'data', self.repo_dir + '.tar') | ||||
|         self.assertRaises(KeyError, self.repo.create_blob_fromworkdir, path) | ||||
|  | ||||
|     def test_create_blob_fromdisk(self): | ||||
|  | ||||
|         path = os.path.join(os.path.dirname(__file__), 'data', self.repo_dir + '.tar') | ||||
|     def test_create_blob_fromdisk(self): | ||||
|         path = join(dirname(__file__), 'data', self.repo_dir + '.tar') | ||||
|         blob_oid = self.repo.create_blob_fromdisk(path) | ||||
|         blob = self.repo[blob_oid] | ||||
|  | ||||
|   | ||||
| @@ -32,6 +32,7 @@ from __future__ import unicode_literals | ||||
| import unittest | ||||
| import pygit2 | ||||
| from pygit2 import GIT_DIFF_INCLUDE_UNMODIFIED | ||||
| from pygit2 import GIT_DIFF_IGNORE_WHITESPACE, GIT_DIFF_IGNORE_WHITESPACE_EOL | ||||
| from . import utils | ||||
| from itertools import chain | ||||
|  | ||||
| @@ -183,9 +184,9 @@ class DiffTest(utils.BareRepoTestCase): | ||||
|         diff = commit_a.tree.diff_to_tree() | ||||
|  | ||||
|         def get_context_for_lines(diff): | ||||
|           hunks = chain(*map(lambda x: x.hunks, [p for p in diff])) | ||||
|           lines = chain(*map(lambda x: x.lines, hunks)) | ||||
|           return map(lambda x: x[0], lines) | ||||
|             hunks = chain(*map(lambda x: x.hunks, [p for p in diff])) | ||||
|             lines = chain(*map(lambda x: x.lines, hunks)) | ||||
|             return map(lambda x: x[0], lines) | ||||
|  | ||||
|         entries = [p.new_file_path for p in diff] | ||||
|         self.assertAll(lambda x: commit_a.tree[x], entries) | ||||
| @@ -204,8 +205,8 @@ class DiffTest(utils.BareRepoTestCase): | ||||
|         commit_c = self.repo[COMMIT_SHA1_3] | ||||
|         commit_d = self.repo[COMMIT_SHA1_4] | ||||
|  | ||||
|         for flag in [pygit2.GIT_DIFF_IGNORE_WHITESPACE, | ||||
|                     pygit2.GIT_DIFF_IGNORE_WHITESPACE_EOL]: | ||||
|         for flag in [GIT_DIFF_IGNORE_WHITESPACE, | ||||
|                      GIT_DIFF_IGNORE_WHITESPACE_EOL]: | ||||
|             diff = commit_c.tree.diff_to_tree(commit_d.tree, flag) | ||||
|             self.assertTrue(diff is not None) | ||||
|             self.assertEqual(0, len(diff[0].hunks)) | ||||
| @@ -277,7 +278,7 @@ class DiffTest(utils.BareRepoTestCase): | ||||
|         #~ Must pass GIT_DIFF_INCLUDE_UNMODIFIED if you expect to emulate | ||||
|         #~ --find-copies-harder during rename transformion... | ||||
|         diff = commit_a.tree.diff_to_tree(commit_b.tree, | ||||
|             GIT_DIFF_INCLUDE_UNMODIFIED) | ||||
|                                           GIT_DIFF_INCLUDE_UNMODIFIED) | ||||
|         self.assertAll(lambda x: x.status != 'R', diff) | ||||
|         diff.find_similar() | ||||
|         self.assertAny(lambda x: x.status == 'R', diff) | ||||
|   | ||||
| @@ -129,7 +129,7 @@ class IndexTest(utils.RepoTestCase): | ||||
|     def test_bare_index(self): | ||||
|         index = pygit2.Index(os.path.join(self.repo.path, 'index')) | ||||
|         self.assertEqual([x.hex for x in index], | ||||
|                 [x.hex for x in self.repo.index]) | ||||
|                          [x.hex for x in self.repo.index]) | ||||
|  | ||||
|         self.assertRaises(pygit2.GitError, lambda: index.add('bye.txt')) | ||||
|  | ||||
|   | ||||
| @@ -180,26 +180,27 @@ class ReferencesTest(utils.RepoTestCase): | ||||
|  | ||||
|         # try to create existing reference with force | ||||
|         reference =  self.repo.create_reference('refs/tags/version1', | ||||
|                         LAST_COMMIT, force=True) | ||||
|                                                 LAST_COMMIT, force=True) | ||||
|         self.assertEqual(reference.target.hex, LAST_COMMIT) | ||||
|  | ||||
|  | ||||
|     def test_create_symbolic_reference(self): | ||||
|         repo = self.repo | ||||
|         # We add a tag as a new symbolic reference that always points to | ||||
|         # "refs/heads/master" | ||||
|         reference = self.repo.create_reference('refs/tags/beta', | ||||
|         reference = repo.create_reference('refs/tags/beta', | ||||
|                                           'refs/heads/master') | ||||
|         self.assertEqual(reference.type, GIT_REF_SYMBOLIC) | ||||
|         self.assertEqual(reference.target, 'refs/heads/master') | ||||
|  | ||||
|  | ||||
|         # try to create existing symbolic reference | ||||
|         self.assertRaises(ValueError, self.repo.create_reference, | ||||
|         self.assertRaises(ValueError, repo.create_reference, | ||||
|                           'refs/tags/beta', 'refs/heads/master') | ||||
|  | ||||
|         # try to create existing symbolic reference with force | ||||
|         reference =  self.repo.create_reference('refs/tags/beta', | ||||
|                                            'refs/heads/master', force=True) | ||||
|         reference = repo.create_reference('refs/tags/beta', | ||||
|                                           'refs/heads/master', force=True) | ||||
|         self.assertEqual(reference.type, GIT_REF_SYMBOLIC) | ||||
|         self.assertEqual(reference.target, 'refs/heads/master') | ||||
|  | ||||
|   | ||||
| @@ -44,7 +44,7 @@ class RepositoryTest(utils.RepoTestCase): | ||||
|         name = 'upstream' | ||||
|         url = 'git://github.com/libgit2/pygit2.git' | ||||
|  | ||||
|         remote = self.repo.create_remote(name, url); | ||||
|         remote = self.repo.create_remote(name, url) | ||||
|  | ||||
|         self.assertEqual(type(remote), pygit2.Remote) | ||||
|         self.assertEqual(name, remote.name) | ||||
| @@ -94,7 +94,7 @@ class RepositoryTest(utils.RepoTestCase): | ||||
|  | ||||
|         name = 'upstream' | ||||
|         url = 'git://github.com/libgit2/pygit2.git' | ||||
|         remote = self.repo.create_remote(name, url); | ||||
|         remote = self.repo.create_remote(name, url) | ||||
|         self.assertTrue(remote.name in [x.name for x in self.repo.remotes]) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -35,34 +35,6 @@ import pygit2 | ||||
| from . import utils | ||||
|  | ||||
|  | ||||
| EXPECTED = { | ||||
|     "current_file":                    pygit2.GIT_STATUS_CURRENT, | ||||
|     "file_deleted":                    pygit2.GIT_STATUS_WT_DELETED, | ||||
|     "modified_file":                   pygit2.GIT_STATUS_WT_MODIFIED, | ||||
|     "new_file":                        pygit2.GIT_STATUS_WT_NEW, | ||||
|  | ||||
|     "staged_changes":                  pygit2.GIT_STATUS_INDEX_MODIFIED, | ||||
|     "staged_changes_file_deleted":     pygit2.GIT_STATUS_INDEX_MODIFIED | | ||||
|                                        pygit2.GIT_STATUS_WT_DELETED, | ||||
|     "staged_changes_file_modified":    pygit2.GIT_STATUS_INDEX_MODIFIED | | ||||
|                                        pygit2.GIT_STATUS_WT_MODIFIED, | ||||
|  | ||||
|     "staged_delete":                   pygit2.GIT_STATUS_INDEX_DELETED, | ||||
|     "staged_delete_file_modified":     pygit2.GIT_STATUS_INDEX_DELETED | | ||||
|                                        pygit2.GIT_STATUS_WT_NEW, | ||||
|     "staged_new":                      pygit2.GIT_STATUS_INDEX_NEW, | ||||
|  | ||||
|     "staged_new_file_deleted":         pygit2.GIT_STATUS_INDEX_NEW | | ||||
|                                        pygit2.GIT_STATUS_WT_DELETED, | ||||
|     "staged_new_file_modified":        pygit2.GIT_STATUS_INDEX_NEW | | ||||
|                                        pygit2.GIT_STATUS_WT_MODIFIED, | ||||
|  | ||||
|     "subdir/current_file":             pygit2.GIT_STATUS_CURRENT, | ||||
|     "subdir/deleted_file":             pygit2.GIT_STATUS_WT_DELETED, | ||||
|     "subdir/modified_file":            pygit2.GIT_STATUS_WT_MODIFIED, | ||||
|     "subdir/new_file":                 pygit2.GIT_STATUS_WT_NEW, | ||||
| } | ||||
|  | ||||
| class StatusTest(utils.DirtyRepoTestCase): | ||||
|  | ||||
|     def test_status(self): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 J. David Ibáñez
					J. David Ibáñez