Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2ce1ca

Browse files
committed
test, deps: FIXmock deps on py3.
+ Del extra spaces, import os.path as osp
1 parente50a8e6 commitf2ce1ca

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
importos
8-
importos.path
98
importsys
109
importselect
1110
importlogging
@@ -213,11 +212,11 @@ def _deplete_buffer(fno, handler, buf_list, wg=None):
213212

214213
defdashify(string):
215214
returnstring.replace('_','-')
216-
215+
217216

218217
defslots_to_dict(self,exclude=()):
219218
returndict((s,getattr(self,s))forsinself.__slots__ifsnotinexclude)
220-
219+
221220

222221
defdict_to_slots_and__excluded_are_none(self,d,excluded=()):
223222
fork,vind.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
returnslots_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
ifstderrisNone:
340339
stderr=b''
341340
stderr=force_bytes(stderr)
342-
341+
343342
status=self.proc.wait()
344343

345344
defread_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-
frommockimportpatch
19+
try:
20+
fromunittest.mockimportpatch
21+
exceptImportError:
22+
frommockimportpatch
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
importos
3535
fromdatetimeimportdatetime
3636
fromgit.objects.utilimporttzoffset,utc
37-
frommockimportMock
37+
38+
try:
39+
fromunittest.mockimportMock
40+
exceptImportError:
41+
frommockimportMock
3842

3943

4044
defassert_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
assertre.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
assertnotre.search(r"^gpgsig ",cstream.getvalue().decode('ascii'),re.MULTILINE)
358-
362+
359363
defassert_gpgsig_deserialization(self,cstream):
360364
assert'gpgsig'in'precondition: need gpgsig'
361-
365+
362366
classRepoMock:
363367
def__init__(self,bytestr):
364368
self.bytestr=bytestr
365-
369+
366370
@property
367371
defodb(self):
368372
classODBMock:
369373
def__init__(self,bytestr):
370374
self.bytestr=bytestr
371-
375+
372376
defstream(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
returnODBMock(self.bytestr)
378-
382+
379383
repo_mock=RepoMock(cstream.getvalue())
380384
forfieldinCommit.__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
importos
88
importsys
9-
importmock
109
importsubprocess
1110

1211
fromgit.test.libimport (
@@ -28,6 +27,11 @@
2827

2928
fromgit.compatimportPY3
3029

30+
try:
31+
fromunittestimportmock
32+
exceptImportError:
33+
importmock
34+
3135

3236
classTestGit(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
ifsys.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)

[8]ページ先頭

©2009-2025 Movatter.jp