Fixing coding style with the help of pep8 (wip)
This commit is contained in:
		
							
								
								
									
										10
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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
 | 
			
		||||
@@ -88,8 +90,6 @@ class TestCommand(Command):
 | 
			
		||||
        # 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
 | 
			
		||||
 | 
			
		||||
@@ -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))
 | 
			
		||||
 
 | 
			
		||||
@@ -185,20 +185,21 @@ class ReferencesTest(utils.RepoTestCase):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    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',
 | 
			
		||||
        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