Merge pull request #9911 from bkeyvani/fix-issue-8646

This commit is contained in:
Zac Hatfield-Dodds
2022-05-10 23:53:40 -07:00
committed by GitHub
4 changed files with 19 additions and 0 deletions

View File

@@ -899,6 +899,12 @@ def raises(
"""
__tracebackhide__ = True
if not expected_exception:
raise ValueError(
f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. "
f"Raising exceptions is already understood as failing the test, so you don't need "
f"any special code to say 'this should never raise an exception'."
)
if isinstance(expected_exception, type):
excepted_exceptions: Tuple[Type[E], ...] = (expected_exception,)
else: