@@ -107,7 +107,9 @@ def test_notification(self):
107
107
self .assertTrue (response == verify_response )
108
108
109
109
def test_non_existent_method (self ):
110
- self .assertRaises (ProtocolError , self .client .foobar )
110
+ with self .assertRaises (ProtocolError ):
111
+ self .client .foobar ()
112
+
111
113
request = json .loads (history .request )
112
114
response = json .loads (history .response )
113
115
verify_request = {
@@ -304,7 +306,8 @@ def test_single_kwargs(self):
304
306
305
307
def test_single_kwargs_and_args (self ):
306
308
client = self .get_client ()
307
- self .assertRaises (ProtocolError , client .add , (5 ,), {'y' : 10 })
309
+ with self .assertRaises (ProtocolError ):
310
+ client .add (5 , y = 10 )
308
311
309
312
def test_single_notify (self ):
310
313
client = self .get_client ()
@@ -351,7 +354,8 @@ def test_multicall_failure(self):
351
354
else :
352
355
def func ():
353
356
return result [i ]
354
- self .assertRaises (raises [i ], func )
357
+ with self .assertRaises (raises [i ]):
358
+ func ()
355
359
356
360
357
361
if jsonrpc .USE_UNIX_SOCKETS :
@@ -401,11 +405,8 @@ def setUp(self):
401
405
402
406
def test_client (self ):
403
407
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 )
409
410
410
411
def tearDown (self ):
411
412
jsonrpc .USE_UNIX_SOCKETS = self .original_value
0 commit comments