@@ -239,20 +239,26 @@ def test_seq(self):
239239 self .assertEqual (self .edits ['a' ], f )
240240 self .assertEqual (self .edits .call ('a' , cursor_offset = 3 , line = 'hello' ),
241241 ('hi' , 2 ))
242- self .assertRaises (KeyError , self .edits .__getitem__ , 'b' )
243- self .assertRaises (KeyError , self .edits .call , 'b' )
242+ with self .assertRaises (KeyError ):
243+ self .edits ['b' ]
244+ with self .assertRaises (KeyError ):
245+ self .edits .call ('b' )
244246
245247 def test_functions_with_bad_signatures (self ):
246248 f = lambda something : (1 , 2 )
247- self .assertRaises (TypeError , self .edits .add , 'a' , f )
249+ with self .assertRaises (TypeError ):
250+ self .edits .add ('a' , f )
248251 g = lambda cursor_offset , line , something , something_else : (1 , 2 )
249- self .assertRaises (TypeError , self .edits .add , 'a' , g )
252+ with self .assertRaises (TypeError ):
253+ self .edits .add ('a' , g )
250254
251255 def test_functions_with_bad_return_values (self ):
252256 f = lambda cursor_offset , line : ('hi' ,)
253- self .assertRaises (ValueError , self .edits .add , 'a' , f )
257+ with self .assertRaises (ValueError ):
258+ self .edits .add ('a' , f )
254259 g = lambda cursor_offset , line : ('hi' , 1 , 2 , 3 )
255- self .assertRaises (ValueError , self .edits .add , 'b' , g )
260+ with self .assertRaises (ValueError ):
261+ self .edits .add ('b' , g )
256262
257263 def test_config (self ):
258264 f = lambda cursor_offset , line : ('hi' , 2 )
@@ -267,10 +273,10 @@ class config(object):
267273 configured_edits = self .edits .mapping_with_config (config , key_dispatch )
268274 self .assertTrue (configured_edits .__contains__ , 'c' )
269275 self .assertNotIn ('c' , self .edits )
270- self .assertRaises (NotImplementedError ,
271- configured_edits .add_config_attr , 'att2' , g )
272- self .assertRaises (NotImplementedError ,
273- configured_edits .add , 'd' , g )
276+ with self .assertRaises (NotImplementedError ):
277+ configured_edits .add_config_attr ( 'att2' , g )
278+ with self .assertRaises (NotImplementedError ):
279+ configured_edits .add ( 'd' , g )
274280 self .assertEqual (configured_edits .call ('c' , cursor_offset = 5 ,
275281 line = 'asfd' ),
276282 ('hi' , 2 ))
0 commit comments