mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	assertRaises as context manager now allows you to access exception as documented
This commit is contained in:
		
							parent
							
								
									a4f46e1292
								
							
						
					
					
						commit
						2bd52dcccb
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		|  | @ -3059,8 +3059,13 @@ def _raise(e): | |||
|             pass | ||||
|         else: | ||||
|             self.fail("assertRaises() didn't let exception pass through") | ||||
|         with self.assertRaises(KeyError): | ||||
|             raise KeyError | ||||
|         with self.assertRaises(KeyError) as cm: | ||||
|             try: | ||||
|                 raise KeyError | ||||
|             except Exception, e: | ||||
|                 raise | ||||
|         self.assertIs(cm.exception, e) | ||||
| 
 | ||||
|         with self.assertRaises(KeyError): | ||||
|             raise KeyError("key") | ||||
|         try: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Michael Foord
						Michael Foord