| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,6 @@ | |||
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | 7 | import os | |
| 8 | - import os.path | ||
| 9 | 8 | import sys | |
| 10 | 9 | import select | |
| 11 | 10 | import logging | |
@@ -213,11 +212,11 @@ def _deplete_buffer(fno, handler, buf_list, wg=None): | |||
| 213 | 212 | ||
| 214 | 213 | def dashify(string): | |
| 215 | 214 | return string.replace('_', '-') | |
| 216 | - | ||
| 215 | + | ||
| 217 | 216 | ||
| 218 | 217 | def slots_to_dict(self, exclude=()): | |
| 219 | 218 | return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude) | |
| 220 | - | ||
| 219 | + | ||
| 221 | 220 | ||
| 222 | 221 | def dict_to_slots_and__excluded_are_none(self, d, excluded=()): | |
| 223 | 222 | for k, v in d.items(): | |
@@ -246,15 +245,15 @@ class Git(LazyMixin): | |||
| 246 | 245 | """ | |
| 247 | 246 | __slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info", | |
| 248 | 247 | "_git_options", "_environment") | |
| 249 | - | ||
| 248 | + | ||
| 250 | 249 | _excluded_ = ('cat_file_all', 'cat_file_header', '_version_info') | |
| 251 | - | ||
| 250 | + | ||
| 252 | 251 | def __getstate__(self): | |
| 253 | 252 | return slots_to_dict(self, exclude=self._excluded_) | |
| 254 | - | ||
| 253 | + | ||
| 255 | 254 | def __setstate__(self, d): | |
| 256 | 255 | dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_) | |
| 257 | - | ||
| 256 | + | ||
| 258 | 257 | # CONFIGURATION | |
| 259 | 258 | # The size in bytes read from stdout when copying git's output to another stream | |
| 260 | 259 | max_chunk_size = 1024 * 64 | |
@@ -267,7 +266,7 @@ def __setstate__(self, d): | |||
| 267 | 266 | ||
| 268 | 267 | # value of Windows process creation flag taken from MSDN | |
| 269 | 268 | CREATE_NO_WINDOW = 0x08000000 | |
| 270 | - | ||
| 269 | + | ||
| 271 | 270 | # Provide the full path to the git executable. Otherwise it assumes git is in the path | |
| 272 | 271 | _git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE" | |
| 273 | 272 | GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name) | |
@@ -339,7 +338,7 @@ def wait(self, stderr=b''): | |||
| 339 | 338 | if stderr is None: | |
| 340 | 339 | stderr = b'' | |
| 341 | 340 | stderr = force_bytes(stderr) | |
| 342 | - | ||
| 341 | + | ||
| 343 | 342 | status = self.proc.wait() | |
| 344 | 343 | ||
| 345 | 344 | def read_all_from_possibly_closed_stream(stream): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,10 @@ | |||
| 16 | 16 | assert_false | |
| 17 | 17 | ) | |
| 18 | 18 | ||
| 19 | - from mock import patch | ||
| 19 | + try: | ||
| 20 | + from unittest.mock import patch | ||
| 21 | + except ImportError: | ||
| 22 | + from mock import patch | ||
| 20 | 23 | ||
| 21 | 24 | __all__ = ['assert_instance_of', 'assert_not_instance_of', | |
| 22 | 25 | 'assert_none', 'assert_not_none', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,11 @@ | |||
| 34 | 34 | import os | |
| 35 | 35 | from datetime import datetime | |
| 36 | 36 | 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 | ||
| 38 | 42 | ||
| 39 | 43 | ||
| 40 | 44 | def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False): | |
@@ -343,9 +347,9 @@ def test_gpgsig(self): | |||
| 343 | 347 | cstream = BytesIO() | |
| 344 | 348 | cmt._serialize(cstream) | |
| 345 | 349 | assert re.search(r"^gpgsig <test\n dummy\n sig>$", cstream.getvalue().decode('ascii'), re.MULTILINE) | |
| 346 | - | ||
| 350 | + | ||
| 347 | 351 | self.assert_gpgsig_deserialization(cstream) | |
| 348 | - | ||
| 352 | + | ||
| 349 | 353 | cstream.seek(0) | |
| 350 | 354 | cmt.gpgsig = None | |
| 351 | 355 | cmt._deserialize(cstream) | |
@@ -355,27 +359,27 @@ def test_gpgsig(self): | |||
| 355 | 359 | cstream = BytesIO() | |
| 356 | 360 | cmt._serialize(cstream) | |
| 357 | 361 | assert not re.search(r"^gpgsig ", cstream.getvalue().decode('ascii'), re.MULTILINE) | |
| 358 | - | ||
| 362 | + | ||
| 359 | 363 | def assert_gpgsig_deserialization(self, cstream): | |
| 360 | 364 | assert 'gpgsig' in 'precondition: need gpgsig' | |
| 361 | - | ||
| 365 | + | ||
| 362 | 366 | class RepoMock: | |
| 363 | 367 | def __init__(self, bytestr): | |
| 364 | 368 | self.bytestr = bytestr | |
| 365 | - | ||
| 369 | + | ||
| 366 | 370 | @property | |
| 367 | 371 | def odb(self): | |
| 368 | 372 | class ODBMock: | |
| 369 | 373 | def __init__(self, bytestr): | |
| 370 | 374 | self.bytestr = bytestr | |
| 371 | - | ||
| 375 | + | ||
| 372 | 376 | def stream(self, *args): | |
| 373 | 377 | stream = Mock(spec_set=['read'], return_value=self.bytestr) | |
| 374 | 378 | stream.read.return_value = self.bytestr | |
| 375 | 379 | return ('binsha', 'typename', 'size', stream) | |
| 376 | - | ||
| 380 | + | ||
| 377 | 381 | return ODBMock(self.bytestr) | |
| 378 | - | ||
| 382 | + | ||
| 379 | 383 | repo_mock = RepoMock(cstream.getvalue()) | |
| 380 | 384 | for field in Commit.__slots__: | |
| 381 | 385 | c = Commit(repo_mock, b'x' * 20) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ | |||
| 6 | 6 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 7 | 7 | import os | |
| 8 | 8 | import sys | |
| 9 | - import mock | ||
| 10 | 9 | import subprocess | |
| 11 | 10 | ||
| 12 | 11 | from git.test.lib import ( | |
@@ -28,6 +27,11 @@ | |||
| 28 | 27 | ||
| 29 | 28 | from git.compat import PY3 | |
| 30 | 29 | ||
| 30 | + try: | ||
| 31 | + from unittest import mock | ||
| 32 | + except ImportError: | ||
| 33 | + import mock | ||
| 34 | + | ||
| 31 | 35 | ||
| 32 | 36 | class TestGit(TestBase): | |
| 33 | 37 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,8 +68,10 @@ def _stamp_version(filename): | |||
| 68 | 68 | print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr) | |
| 69 | 69 | ||
| 70 | 70 | install_requires = ['gitdb >= 0.6.4'] | |
| 71 | + test_requires = ['node'] | ||
| 71 | 72 | if sys.version_info[:2] < (2, 7): | |
| 72 | 73 | install_requires.append('ordereddict') | |
| 74 | + test_requires.append('mock') | ||
| 73 | 75 | # end | |
| 74 | 76 | ||
| 75 | 77 | setup( | |
@@ -87,7 +89,7 @@ def _stamp_version(filename): | |||
| 87 | 89 | license="BSD License", | |
| 88 | 90 | requires=['gitdb (>=0.6.4)'], | |
| 89 | 91 | install_requires=install_requires, | |
| 90 | - test_requirements=['mock', 'nose'] + install_requires, | ||
| 92 | + test_requirements=test_requires + install_requires, | ||
| 91 | 93 | zip_safe=False, | |
| 92 | 94 | long_description="""\ | |
| 93 | 95 | GitPython is a python library used to interact with Git repositories""", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments