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

Commit 99b6dff

Browse files
Remove test.lib.asserts and use unittest.mock.patch directly
1 parent 8a5a78b commit 99b6dff

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

‎git/test/lib/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
# flake8: noqa
88
import inspect
9-
from .asserts import *
109
from .helper import *
1110

1211
__all__ = [name for name, obj in locals().items()

‎git/test/lib/asserts.py‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎git/test/test_git.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from git.compat import is_darwin
2222
from git.test.lib import (
2323
TestBase,
24-
patch,
2524
fixture_path
2625
)
2726
from git.test.lib import with_rw_directory
@@ -43,7 +42,7 @@ def tearDown(self):
4342
import gc
4443
gc.collect()
4544

46-
@patch.object(Git, 'execute')
45+
@mock.patch.object(Git, 'execute')
4746
def test_call_process_calls_execute(self, git):
4847
git.return_value = ''
4948
self.git.version()
@@ -90,7 +89,7 @@ def test_it_accepts_stdin(self):
9089
self.assertEqual("70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
9190
self.git.hash_object(istream=fh, stdin=True))
9291

93-
@patch.object(Git, 'execute')
92+
@mock.patch.object(Git, 'execute')
9493
def test_it_ignores_false_kwargs(self, git):
9594
# this_should_not_be_ignored=False implies it *should* be ignored
9695
self.git.version(pass_this_kwarg=False)

‎git/test/test_repo.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pathlib
1313
import pickle
1414
import tempfile
15-
from unittest import skipIf, SkipTest
15+
from unittest import mock, skipIf, SkipTest
1616

1717
from git import (
1818
InvalidGitRepositoryError,
@@ -37,7 +37,6 @@
3737
)
3838
from git.repo.fun import touch
3939
from git.test.lib import (
40-
patch,
4140
TestBase,
4241
with_rw_repo,
4342
fixture
@@ -393,7 +392,7 @@ def test_archive(self):
393392
assert stream.tell()
394393
os.remove(tmpfile)
395394

396-
@patch.object(Git, '_call_process')
395+
@mock.patch.object(Git, '_call_process')
397396
def test_should_display_blame_information(self, git):
398397
git.return_value = fixture('blame')
399398
b = self.rorepo.blame('master', 'lib/git.py')
@@ -437,7 +436,7 @@ def test_blame_real(self):
437436
assert c, "Should have executed at least one blame command"
438437
assert nml, "There should at least be one blame commit that contains multiple lines"
439438

440-
@patch.object(Git, '_call_process')
439+
@mock.patch.object(Git, '_call_process')
441440
def test_blame_incremental(self, git):
442441
# loop over two fixtures, create a test fixture for 2.11.1+ syntax
443442
for git_fixture in ('blame_incremental', 'blame_incremental_2.11.1_plus'):
@@ -460,7 +459,7 @@ def test_blame_incremental(self, git):
460459
orig_ranges = flatten([entry.orig_linenos for entry in blame_output])
461460
self.assertEqual(orig_ranges, flatten([range(2, 3), range(14, 15), range(1, 2), range(2, 13), range(13, 15)])) # noqa E501
462461

463-
@patch.object(Git, '_call_process')
462+
@mock.patch.object(Git, '_call_process')
464463
def test_blame_complex_revision(self, git):
465464
git.return_value = fixture('blame_complex_revision')
466465
res = self.rorepo.blame("HEAD~10..HEAD", "README.md")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /