MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / assert_warns

Function assert_warns

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

405
406
407def assert_warns(except_cls, callable_, *args, **kwargs):
408 """legacy adapter function for functions that were previously using
409 assert_raises with SAWarning or similar.
410
411 has some workarounds to accommodate the fact that the callable completes
412 with this approach rather than stopping at the exception raise.
413
414
415 """
416 with _expect_warnings_sqla_only(except_cls, [".*"]):
417 return callable_(*args, **kwargs)
418
419
420def 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