diff options
author | Harmon <Harmon758@gmail.com> | 2020-02-16 17:44:22 -0600 |
---|---|---|
committer | Harmon <Harmon758@gmail.com> | 2020-02-16 17:44:22 -0600 |
commit | 99b6dffe9604f86f08c2b53bef4f8ab35bb565a1 (patch) | |
tree | 6a6dfbce3c91801ea46be5ae08c0747526ce6d2d /git | |
parent | 8a5a78b27ce1bcda6597b340d47a20efbac478d7 (diff) | |
download | gitpython-99b6dffe9604f86f08c2b53bef4f8ab35bb565a1.tar.gz |
Remove test.lib.asserts and use unittest.mock.patch directly
Diffstat (limited to 'git')
-rw-r--r-- | git/test/lib/__init__.py | 1 | ||||
-rw-r--r-- | git/test/lib/asserts.py | 9 | ||||
-rw-r--r-- | git/test/test_git.py | 5 | ||||
-rw-r--r-- | git/test/test_repo.py | 9 |
4 files changed, 6 insertions, 18 deletions
diff --git a/git/test/lib/__init__.py b/git/test/lib/__init__.py index 87e26752..1551ce45 100644 --- a/git/test/lib/__init__.py +++ b/git/test/lib/__init__.py @@ -6,7 +6,6 @@ # flake8: noqa import inspect -from .asserts import * from .helper import * __all__ = [name for name, obj in locals().items() diff --git a/git/test/lib/asserts.py b/git/test/lib/asserts.py deleted file mode 100644 index 6c49a0c3..00000000 --- a/git/test/lib/asserts.py +++ /dev/null @@ -1,9 +0,0 @@ -# asserts.py -# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors -# -# This module is part of GitPython and is released under -# the BSD License: http://www.opensource.org/licenses/bsd-license.php - -from unittest.mock import patch - -__all__ = ['patch'] diff --git a/git/test/test_git.py b/git/test/test_git.py index 75e35ab7..060a4c3c 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -21,7 +21,6 @@ from git import ( from git.compat import is_darwin from git.test.lib import ( TestBase, - patch, fixture_path ) from git.test.lib import with_rw_directory @@ -43,7 +42,7 @@ class TestGit(TestBase): import gc gc.collect() - @patch.object(Git, 'execute') + @mock.patch.object(Git, 'execute') def test_call_process_calls_execute(self, git): git.return_value = '' self.git.version() @@ -90,7 +89,7 @@ class TestGit(TestBase): self.assertEqual("70c379b63ffa0795fdbfbc128e5a2818397b7ef8", self.git.hash_object(istream=fh, stdin=True)) - @patch.object(Git, 'execute') + @mock.patch.object(Git, 'execute') def test_it_ignores_false_kwargs(self, git): # this_should_not_be_ignored=False implies it *should* be ignored self.git.version(pass_this_kwarg=False) diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 45a51fa6..6fcbc17a 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -12,7 +12,7 @@ import os import pathlib import pickle import tempfile -from unittest import skipIf, SkipTest +from unittest import mock, skipIf, SkipTest from git import ( InvalidGitRepositoryError, @@ -37,7 +37,6 @@ from git.exc import ( ) from git.repo.fun import touch from git.test.lib import ( - patch, TestBase, with_rw_repo, fixture @@ -393,7 +392,7 @@ class TestRepo(TestBase): assert stream.tell() os.remove(tmpfile) - @patch.object(Git, '_call_process') + @mock.patch.object(Git, '_call_process') def test_should_display_blame_information(self, git): git.return_value = fixture('blame') b = self.rorepo.blame('master', 'lib/git.py') @@ -437,7 +436,7 @@ class TestRepo(TestBase): assert c, "Should have executed at least one blame command" assert nml, "There should at least be one blame commit that contains multiple lines" - @patch.object(Git, '_call_process') + @mock.patch.object(Git, '_call_process') def test_blame_incremental(self, git): # loop over two fixtures, create a test fixture for 2.11.1+ syntax for git_fixture in ('blame_incremental', 'blame_incremental_2.11.1_plus'): @@ -460,7 +459,7 @@ class TestRepo(TestBase): orig_ranges = flatten([entry.orig_linenos for entry in blame_output]) self.assertEqual(orig_ranges, flatten([range(2, 3), range(14, 15), range(1, 2), range(2, 13), range(13, 15)])) # noqa E501 - @patch.object(Git, '_call_process') + @mock.patch.object(Git, '_call_process') def test_blame_complex_revision(self, git): git.return_value = fixture('blame_complex_revision') res = self.rorepo.blame("HEAD~10..HEAD", "README.md") |