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

Function assert_warns

lib/sqlalchemy/testing/assertions.py:401–411  ·  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.

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

Source from the content-addressed store, hash-verified

399
400
401def assert_warns(except_cls, callable_, *args, **kwargs):
402 """legacy adapter function for functions that were previously using
403 assert_raises with SAWarning or similar.
404
405 has some workarounds to accommodate the fact that the callable completes
406 with this approach rather than stopping at the exception raise.
407
408
409 """
410 with _expect_warnings_sqla_only(except_cls, [".*"]):
411 return callable_(*args, **kwargs)
412
413
414def assert_warns_message(except_cls, msg, callable_, *args, **kwargs):

Callers 10

test_notsane_warningMethod · 0.90
test_expiredMethod · 0.90
test_pop_existingMethod · 0.90
test_ad_hoc_lazyMethod · 0.90
test_unknown_typesMethod · 0.90

Calls 1

Tested by 10

test_notsane_warningMethod · 0.72
test_expiredMethod · 0.72
test_pop_existingMethod · 0.72
test_ad_hoc_lazyMethod · 0.72
test_unknown_typesMethod · 0.72