Skip to content

Commit eca6951

Browse files
committed
Replace raises with assertRaises
1 parent c8c63ab commit eca6951

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

git/test/lib/asserts.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
from unittest.mock import patch
88

99
from nose.tools import (
10-
raises, # @UnusedImport
1110
assert_true, # @UnusedImport
1211
assert_false # @UnusedImport
1312
)
1413

15-
__all__ = ['patch', 'raises', 'assert_true', 'assert_false']
14+
__all__ = ['patch', 'assert_true', 'assert_false']

git/test/test_git.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from git.test.lib import (
2323
TestBase,
2424
patch,
25-
raises,
2625
assert_true,
2726
fixture_path
2827
)
@@ -62,9 +61,8 @@ def test_call_unpack_args(self):
6261
mangled_value = 'Unicode\u20ac\u2122'
6362
self.assertEqual(args, ['git', 'log', '--', mangled_value])
6463

65-
@raises(GitCommandError)
6664
def test_it_raises_errors(self):
67-
self.git.this_does_not_exist()
65+
self.assertRaises(GitCommandError, self.git.this_does_not_exist)
6866

6967
def test_it_transforms_kwargs_into_git_command_arguments(self):
7068
self.assertEqual(["-s"], self.git.transform_kwargs(**{'s': True}))
@@ -99,10 +97,9 @@ def test_it_ignores_false_kwargs(self, git):
9997
self.git.version(pass_this_kwarg=False)
10098
assert_true("pass_this_kwarg" not in git.call_args[1])
10199

102-
@raises(GitCommandError)
103100
def test_it_raises_proper_exception_with_output_stream(self):
104101
tmp_file = TemporaryFile()
105-
self.git.checkout('non-existent-branch', output_stream=tmp_file)
102+
self.assertRaises(GitCommandError, self.git.checkout, 'non-existent-branch', output_stream=tmp_file)
106103

107104
def test_it_accepts_environment_variables(self):
108105
filename = fixture_path("ls_tree_empty")

git/test/test_repo.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
with_rw_repo,
4343
fixture,
4444
assert_false,
45-
assert_true,
46-
raises
45+
assert_true
4746
)
4847
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
4948
from git.test.lib import with_rw_directory
@@ -82,13 +81,11 @@ def tearDown(self):
8281
import gc
8382
gc.collect()
8483

85-
@raises(InvalidGitRepositoryError)
8684
def test_new_should_raise_on_invalid_repo_location(self):
87-
Repo(tempfile.gettempdir())
85+
self.assertRaises(InvalidGitRepositoryError, Repo, tempfile.gettempdir())
8886

89-
@raises(NoSuchPathError)
9087
def test_new_should_raise_on_non_existent_path(self):
91-
Repo("repos/foobar")
88+
self.assertRaises(NoSuchPathError, Repo, "repos/foobar")
9289

9390
@with_rw_repo('0.3.2.1')
9491
def test_repo_creation_from_different_paths(self, rw_repo):

0 commit comments

Comments
 (0)