Let context-managers for raises and warns handle unknown keyword arguments
As suggested during review
This commit is contained in:
		
							parent
							
								
									0ed7aa2db6
								
							
						
					
					
						commit
						dfe54cd82f
					
				|  | @ -651,12 +651,9 @@ def raises(expected_exception, *args, match=None, **kwargs): | ||||||
|     message = "DID NOT RAISE {}".format(expected_exception) |     message = "DID NOT RAISE {}".format(expected_exception) | ||||||
| 
 | 
 | ||||||
|     if not args: |     if not args: | ||||||
|         if kwargs: |         return RaisesContext( | ||||||
|             msg = "Unexpected keyword arguments passed to pytest.raises: " |             expected_exception, message=message, match_expr=match, **kwargs | ||||||
|             msg += ", ".join(sorted(kwargs)) |         ) | ||||||
|             msg += "\nUse context-manager form instead?" |  | ||||||
|             raise TypeError(msg) |  | ||||||
|         return RaisesContext(expected_exception, message, match) |  | ||||||
|     else: |     else: | ||||||
|         func = args[0] |         func = args[0] | ||||||
|         if not callable(func): |         if not callable(func): | ||||||
|  |  | ||||||
|  | @ -76,12 +76,7 @@ def warns(expected_warning, *args, match=None, **kwargs): | ||||||
|     """ |     """ | ||||||
|     __tracebackhide__ = True |     __tracebackhide__ = True | ||||||
|     if not args: |     if not args: | ||||||
|         if kwargs: |         return WarningsChecker(expected_warning, match_expr=match, **kwargs) | ||||||
|             msg = "Unexpected keyword arguments passed to pytest.warns: " |  | ||||||
|             msg += ", ".join(sorted(kwargs)) |  | ||||||
|             msg += "\nUse context-manager form instead?" |  | ||||||
|             raise TypeError(msg) |  | ||||||
|         return WarningsChecker(expected_warning, match_expr=match) |  | ||||||
|     else: |     else: | ||||||
|         func = args[0] |         func = args[0] | ||||||
|         if not callable(func): |         if not callable(func): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue