diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-03-27 10:52:58 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-03-27 11:14:24 -0400 |
commit | c0a224aba3d4e2a41f92a29f9d18c6cb9d09d61f (patch) | |
tree | 4c737f68b3a9f2430f3d1c17af8c202eb6dd9a27 /lib/sqlalchemy/testing/assertions.py | |
parent | f214f4d4f46de24008c63f2e034329a64f510833 (diff) | |
download | sqlalchemy-c0a224aba3d4e2a41f92a29f9d18c6cb9d09d61f.tar.gz |
Add safe_reraise() + warnings only to Connection._autorollback
Added an exception handler that will warn for the "cause" exception on
Py2K when the "autorollback" feature of :class:`.Connection` itself
raises an exception. In Py3K, the two exceptions are naturally reported
by the interpreter as one occurring during the handling of the other.
This is continuing with the series of changes for rollback failure
handling that were last visited as part of :ticket:`2696` in 1.0.12.
Change-Id: I600ba455a14ebaea27c6189889181f97c632f179
Fixes: #3946
Diffstat (limited to 'lib/sqlalchemy/testing/assertions.py')
-rw-r--r-- | lib/sqlalchemy/testing/assertions.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 0244f18a9..884556345 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -10,11 +10,11 @@ from __future__ import absolute_import from . import util as testutil from sqlalchemy import pool, orm, util from sqlalchemy.engine import default, url -from sqlalchemy.util import decorator +from sqlalchemy.util import decorator, compat from sqlalchemy import types as sqltypes, schema, exc as sa_exc import warnings import re -from .exclusions import db_spec, _is_excluded +from .exclusions import db_spec from . import assertsql from . import config from .util import fail @@ -118,7 +118,8 @@ def uses_deprecated(*messages): @contextlib.contextmanager -def _expect_warnings(exc_cls, messages, regex=True, assert_=True): +def _expect_warnings(exc_cls, messages, regex=True, assert_=True, + py2konly=False): if regex: filters = [re.compile(msg, re.I | re.S) for msg in messages] @@ -147,7 +148,7 @@ def _expect_warnings(exc_cls, messages, regex=True, assert_=True): with mock.patch("warnings.warn", our_warn): yield - if assert_: + if assert_ and (not py2konly or not compat.py3k): assert not seen, "Warnings were not seen: %s" % \ ", ".join("%r" % (s.pattern if regex else s) for s in seen) |