Skip to content

Commit f2ce1ca

Browse files
committed
test, deps: FIX mock deps on py3.
+ Del extra spaces, import os.path as osp
1 parent e50a8e6 commit f2ce1ca

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

git/cmd.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import os
8-
import os.path
98
import sys
109
import select
1110
import logging
@@ -213,11 +212,11 @@ def _deplete_buffer(fno, handler, buf_list, wg=None):
213212

214213
def dashify(string):
215214
return string.replace('_', '-')
216-
215+
217216

218217
def slots_to_dict(self, exclude=()):
219218
return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude)
220-
219+
221220

222221
def dict_to_slots_and__excluded_are_none(self, d, excluded=()):
223222
for k, v in d.items():
@@ -246,15 +245,15 @@ class Git(LazyMixin):
246245
"""
247246
__slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info",
248247
"_git_options", "_environment")
249-
248+
250249
_excluded_ = ('cat_file_all', 'cat_file_header', '_version_info')
251-
250+
252251
def __getstate__(self):
253252
return slots_to_dict(self, exclude=self._excluded_)
254-
253+
255254
def __setstate__(self, d):
256255
dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_)
257-
256+
258257
# CONFIGURATION
259258
# The size in bytes read from stdout when copying git's output to another stream
260259
max_chunk_size = 1024 * 64
@@ -267,7 +266,7 @@ def __setstate__(self, d):
267266

268267
# value of Windows process creation flag taken from MSDN
269268
CREATE_NO_WINDOW = 0x08000000
270-
269+
271270
# Provide the full path to the git executable. Otherwise it assumes git is in the path
272271
_git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
273272
GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
@@ -339,7 +338,7 @@ def wait(self, stderr=b''):
339338
if stderr is None:
340339
stderr = b''
341340
stderr = force_bytes(stderr)
342-
341+
343342
status = self.proc.wait()
344343

345344
def read_all_from_possibly_closed_stream(stream):

git/test/lib/asserts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
assert_false
1717
)
1818

19-
from mock import patch
19+
try:
20+
from unittest.mock import patch
21+
except ImportError:
22+
from mock import patch
2023

2124
__all__ = ['assert_instance_of', 'assert_not_instance_of',
2225
'assert_none', 'assert_not_none',

git/test/test_commit.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
import os
3535
from datetime import datetime
3636
from git.objects.util import tzoffset, utc
37-
from mock import Mock
37+
38+
try:
39+
from unittest.mock import Mock
40+
except ImportError:
41+
from mock import Mock
3842

3943

4044
def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False):
@@ -343,9 +347,9 @@ def test_gpgsig(self):
343347
cstream = BytesIO()
344348
cmt._serialize(cstream)
345349
assert re.search(r"^gpgsig <test\n dummy\n sig>$", cstream.getvalue().decode('ascii'), re.MULTILINE)
346-
350+
347351
self.assert_gpgsig_deserialization(cstream)
348-
352+
349353
cstream.seek(0)
350354
cmt.gpgsig = None
351355
cmt._deserialize(cstream)
@@ -355,27 +359,27 @@ def test_gpgsig(self):
355359
cstream = BytesIO()
356360
cmt._serialize(cstream)
357361
assert not re.search(r"^gpgsig ", cstream.getvalue().decode('ascii'), re.MULTILINE)
358-
362+
359363
def assert_gpgsig_deserialization(self, cstream):
360364
assert 'gpgsig' in 'precondition: need gpgsig'
361-
365+
362366
class RepoMock:
363367
def __init__(self, bytestr):
364368
self.bytestr = bytestr
365-
369+
366370
@property
367371
def odb(self):
368372
class ODBMock:
369373
def __init__(self, bytestr):
370374
self.bytestr = bytestr
371-
375+
372376
def stream(self, *args):
373377
stream = Mock(spec_set=['read'], return_value=self.bytestr)
374378
stream.read.return_value = self.bytestr
375379
return ('binsha', 'typename', 'size', stream)
376-
380+
377381
return ODBMock(self.bytestr)
378-
382+
379383
repo_mock = RepoMock(cstream.getvalue())
380384
for field in Commit.__slots__:
381385
c = Commit(repo_mock, b'x' * 20)

git/test/test_git.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
77
import os
88
import sys
9-
import mock
109
import subprocess
1110

1211
from git.test.lib import (
@@ -28,6 +27,11 @@
2827

2928
from git.compat import PY3
3029

30+
try:
31+
from unittest import mock
32+
except ImportError:
33+
import mock
34+
3135

3236
class TestGit(TestBase):
3337

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def _stamp_version(filename):
6868
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
6969

7070
install_requires = ['gitdb >= 0.6.4']
71+
test_requires = ['node']
7172
if sys.version_info[:2] < (2, 7):
7273
install_requires.append('ordereddict')
74+
test_requires.append('mock')
7375
# end
7476

7577
setup(
@@ -87,7 +89,7 @@ def _stamp_version(filename):
8789
license="BSD License",
8890
requires=['gitdb (>=0.6.4)'],
8991
install_requires=install_requires,
90-
test_requirements=['mock', 'nose'] + install_requires,
92+
test_requirements=test_requires + install_requires,
9193
zip_safe=False,
9294
long_description="""\
9395
GitPython is a python library used to interact with Git repositories""",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy