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)
|
||||
|
||||
if not args:
|
||||
if kwargs:
|
||||
msg = "Unexpected keyword arguments passed to pytest.raises: "
|
||||
msg += ", ".join(sorted(kwargs))
|
||||
msg += "\nUse context-manager form instead?"
|
||||
raise TypeError(msg)
|
||||
return RaisesContext(expected_exception, message, match)
|
||||
return RaisesContext(
|
||||
expected_exception, message=message, match_expr=match, **kwargs
|
||||
)
|
||||
else:
|
||||
func = args[0]
|
||||
if not callable(func):
|
||||
|
|
|
@ -76,12 +76,7 @@ def warns(expected_warning, *args, match=None, **kwargs):
|
|||
"""
|
||||
__tracebackhide__ = True
|
||||
if not args:
|
||||
if 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)
|
||||
return WarningsChecker(expected_warning, match_expr=match, **kwargs)
|
||||
else:
|
||||
func = args[0]
|
||||
if not callable(func):
|
||||
|
|
Loading…
Reference in New Issue