@contextlib.contextmanagerdefraises(exception:Snapshot[str]):"""Check that an exception is raised. Parameters: exception: snapshot which is compared with `#!python f"{type}: {message}"` if an exception occured or `#!python "<no exception>"` if no exception was raised. === "original" <!-- inline-snapshot: outcome-passed=1 outcome-errors=1 --> ```python from inline_snapshot import snapshot from inline_snapshot.extra import raises def test_raises(): with raises(snapshot()): 1 / 0 ``` === "--inline-snapshot=create" <!-- inline-snapshot: create outcome-passed=1 --> ```python from inline_snapshot import snapshot from inline_snapshot.extra import raises def test_raises(): with raises(snapshot("ZeroDivisionError: division by zero")): 1 / 0 ``` """try:yieldexceptExceptionasex:msg=str(ex)if"\n"inmsg:assertf"{type(ex).__name__}:\n{ex}"==exceptionelse:assertf"{type(ex).__name__}: {ex}"==exceptionelse:assert"<no exception>"==exception