summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-09-15 00:59:36 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-09-25 18:35:03 +0200
commit7842e92ebaf3fc3380cc8d704afa3841f333748c (patch)
tree0e5b1cdba78bce1c6f26c41945d267a715501d58
parentf73468bb9cb9e479a0b81e3766623c32802db579 (diff)
downloadgitpython-7842e92ebaf3fc3380cc8d704afa3841f333748c.tar.gz
test, deps: FIX `mock` deps on py3.
+ Del extra spaces, import os.path as osp
-rw-r--r--git/cmd.py17
-rw-r--r--git/test/lib/asserts.py5
-rw-r--r--git/test/test_commit.py22
-rw-r--r--git/test/test_git.py6
-rwxr-xr-xsetup.py4
5 files changed, 33 insertions, 21 deletions
diff --git a/git/cmd.py b/git/cmd.py
index ceea2442..1cc656bf 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -5,7 +5,6 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
-import os.path
import sys
import select
import logging
@@ -213,11 +212,11 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer):
def dashify(string):
return string.replace('_', '-')
-
+
def slots_to_dict(self, exclude=()):
return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude)
-
+
def dict_to_slots_and__excluded_are_none(self, d, excluded=()):
for k, v in d.items():
@@ -246,15 +245,15 @@ class Git(LazyMixin):
"""
__slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info",
"_git_options", "_environment")
-
+
_excluded_ = ('cat_file_all', 'cat_file_header', '_version_info')
-
+
def __getstate__(self):
return slots_to_dict(self, exclude=self._excluded_)
-
+
def __setstate__(self, d):
dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_)
-
+
# CONFIGURATION
# The size in bytes read from stdout when copying git's output to another stream
max_chunk_size = 1024 * 64
@@ -267,7 +266,7 @@ class Git(LazyMixin):
# value of Windows process creation flag taken from MSDN
CREATE_NO_WINDOW = 0x08000000
-
+
# Provide the full path to the git executable. Otherwise it assumes git is in the path
_git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
@@ -339,7 +338,7 @@ class Git(LazyMixin):
if stderr is None:
stderr = b''
stderr = force_bytes(stderr)
-
+
status = self.proc.wait()
def read_all_from_possibly_closed_stream(stream):
diff --git a/git/test/lib/asserts.py b/git/test/lib/asserts.py
index 60a888b3..9edc49e0 100644
--- a/git/test/lib/asserts.py
+++ b/git/test/lib/asserts.py
@@ -16,7 +16,10 @@ from nose.tools import (
assert_false
)
-from mock import patch
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
__all__ = ['assert_instance_of', 'assert_not_instance_of',
'assert_none', 'assert_not_none',
diff --git a/git/test/test_commit.py b/git/test/test_commit.py
index c0599503..805221ac 100644
--- a/git/test/test_commit.py
+++ b/git/test/test_commit.py
@@ -34,7 +34,11 @@ import re
import os
from datetime import datetime
from git.objects.util import tzoffset, utc
-from mock import Mock
+
+try:
+ from unittest.mock import Mock
+except ImportError:
+ from mock import Mock
def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False):
@@ -343,9 +347,9 @@ JzJMZDRLQLFvnzqZuCjE
cstream = BytesIO()
cmt._serialize(cstream)
assert re.search(r"^gpgsig <test\n dummy\n sig>$", cstream.getvalue().decode('ascii'), re.MULTILINE)
-
+
self.assert_gpgsig_deserialization(cstream)
-
+
cstream.seek(0)
cmt.gpgsig = None
cmt._deserialize(cstream)
@@ -355,27 +359,27 @@ JzJMZDRLQLFvnzqZuCjE
cstream = BytesIO()
cmt._serialize(cstream)
assert not re.search(r"^gpgsig ", cstream.getvalue().decode('ascii'), re.MULTILINE)
-
+
def assert_gpgsig_deserialization(self, cstream):
assert 'gpgsig' in 'precondition: need gpgsig'
-
+
class RepoMock:
def __init__(self, bytestr):
self.bytestr = bytestr
-
+
@property
def odb(self):
class ODBMock:
def __init__(self, bytestr):
self.bytestr = bytestr
-
+
def stream(self, *args):
stream = Mock(spec_set=['read'], return_value=self.bytestr)
stream.read.return_value = self.bytestr
return ('binsha', 'typename', 'size', stream)
-
+
return ODBMock(self.bytestr)
-
+
repo_mock = RepoMock(cstream.getvalue())
for field in Commit.__slots__:
c = Commit(repo_mock, b'x' * 20)
diff --git a/git/test/test_git.py b/git/test/test_git.py
index b46ac72d..59796a3d 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -6,7 +6,6 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
import sys
-import mock
import subprocess
from git.test.lib import (
@@ -28,6 +27,11 @@ from gitdb.test.lib import with_rw_directory
from git.compat import PY3
+try:
+ from unittest import mock
+except ImportError:
+ import mock
+
class TestGit(TestBase):
diff --git a/setup.py b/setup.py
index 05c12b8f..b3b43eb3 100755
--- a/setup.py
+++ b/setup.py
@@ -68,8 +68,10 @@ def _stamp_version(filename):
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
install_requires = ['gitdb >= 0.6.4']
+test_requires = ['node']
if sys.version_info[:2] < (2, 7):
install_requires.append('ordereddict')
+ test_requires.append('mock')
# end
setup(
@@ -87,7 +89,7 @@ setup(
license="BSD License",
requires=['gitdb (>=0.6.4)'],
install_requires=install_requires,
- test_requirements=['mock', 'nose'] + install_requires,
+ test_requirements=test_requires + install_requires,
zip_safe=False,
long_description="""\
GitPython is a python library used to interact with Git repositories""",