Skip to content

Commit 402fe6a

Browse files
committed
Fixing assert contexts for <= 2.6 / unittest2
1 parent a39d1f9 commit 402fe6a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ def test_notification(self):
107107
self.assertTrue(response == verify_response)
108108

109109
def test_non_existent_method(self):
110-
self.assertRaises(ProtocolError, self.client.foobar)
110+
with self.assertRaises(ProtocolError):
111+
self.client.foobar()
112+
111113
request = json.loads(history.request)
112114
response = json.loads(history.response)
113115
verify_request = {
@@ -304,7 +306,8 @@ def test_single_kwargs(self):
304306

305307
def test_single_kwargs_and_args(self):
306308
client = self.get_client()
307-
self.assertRaises(ProtocolError, client.add, (5,), {'y': 10})
309+
with self.assertRaises(ProtocolError):
310+
client.add(5, y=10)
308311

309312
def test_single_notify(self):
310313
client = self.get_client()
@@ -351,7 +354,8 @@ def test_multicall_failure(self):
351354
else:
352355
def func():
353356
return result[i]
354-
self.assertRaises(raises[i], func)
357+
with self.assertRaises(raises[i]):
358+
func()
355359

356360

357361
if jsonrpc.USE_UNIX_SOCKETS:
@@ -401,11 +405,8 @@ def setUp(self):
401405

402406
def test_client(self):
403407
address = "unix://shouldnt/work.sock"
404-
self.assertRaises(
405-
jsonrpc.UnixSocketMissing,
406-
Server,
407-
address
408-
)
408+
with self.assertRaises(jsonrpc.UnixSocketMissing):
409+
Server(address)
409410

410411
def tearDown(self):
411412
jsonrpc.USE_UNIX_SOCKETS = self.original_value

0 commit comments

Comments
 (0)