diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-10-09 13:55:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-10-11 11:11:42 -0400 |
commit | 9488480abea15298ded6996aa13b42edf134e467 (patch) | |
tree | 6d6e6a0cac425ea848642d6d065dbecbd8f07a7b /lib/sqlalchemy/testing/assertions.py | |
parent | cab08ea1834ac519f124789b835afa6832972b1c (diff) | |
download | sqlalchemy-9488480abea15298ded6996aa13b42edf134e467.tar.gz |
pass executemany context to _repr_params
Fixed bug where parameter repr as used in logging and error reporting needs
additional context in order to distinguish between a list of parameters for
a single statement and a list of parameter lists, as the "list of lists"
structure could also indicate a single parameter list where the first
parameter itself is a list, such as for an array parameter. The
engine/connection now passes in an additional boolean indicating how the
parameters should be considered. The only SQLAlchemy backend that expects
arrays as parameters is that of psycopg2 which uses pyformat parameters,
so this issue has not been too apparent, however as other drivers that use
positional gain more features it is important that this be supported. It
also eliminates the need for the parameter repr function to guess based on
the parameter structure passed.
Fixes: #4902
Change-Id: I086246ee0eb51484adbefd83e07295fa56576c5f
Diffstat (limited to 'lib/sqlalchemy/testing/assertions.py')
-rw-r--r-- | lib/sqlalchemy/testing/assertions.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 819fedcc7..f057ae37b 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -307,6 +307,20 @@ def assert_raises(except_cls, callable_, *args, **kw): assert success, "Callable did not raise an exception" +def assert_raises_return(except_cls, callable_, *args, **kw): + ret_err = None + try: + callable_(*args, **kw) + success = False + except except_cls as err: + success = True + ret_err = err + + # assert outside the block so it works for AssertionError too ! + assert success, "Callable did not raise an exception" + return ret_err + + def assert_raises_message(except_cls, msg, callable_, *args, **kwargs): try: callable_(*args, **kwargs) |