MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / assert_warns_message

Function assert_warns_message

lib/sqlalchemy/testing/assertions.py:414–431  ·  view source on GitHub ↗

legacy adapter function for functions that were previously using assert_raises with SAWarning or similar. has some workarounds to accommodate the fact that the callable completes with this approach rather than stopping at the exception raise. Also uses regex.search() to match the g

(except_cls, msg, callable_, *args, **kwargs)

Source from the content-addressed store, hash-verified

412
413
414def assert_warns_message(except_cls, msg, callable_, *args, **kwargs):
415 """legacy adapter function for functions that were previously using
416 assert_raises with SAWarning or similar.
417
418 has some workarounds to accommodate the fact that the callable completes
419 with this approach rather than stopping at the exception raise.
420
421 Also uses regex.search() to match the given message to the error string
422 rather than regex.match().
423
424 """
425 with _expect_warnings_sqla_only(
426 except_cls,
427 [msg],
428 search_msg=True,
429 regex=False,
430 ):
431 return callable_(*args, **kwargs)
432
433
434def assert_raises_message_context_ok(

Calls 1