diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-16 18:14:10 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-16 18:14:10 -0500 |
commit | 00c6ebb4408964583943826c831064e1d7472169 (patch) | |
tree | 92f6c24c1828b6394d2a942ec908e442cfcd71f7 /lib/sqlalchemy/testing/warnings.py | |
parent | 5bc3b7fe6b88f12cb39516aa78408c683fc63d0c (diff) | |
download | sqlalchemy-00c6ebb4408964583943826c831064e1d7472169.tar.gz |
- rewrite SQLite reflection tests into one consistent fixture, which tests
both _resolve_type_affinity() directly as well as round trip tests fully.
Diffstat (limited to 'lib/sqlalchemy/testing/warnings.py')
-rw-r--r-- | lib/sqlalchemy/testing/warnings.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index 74a8933a6..849b1b5b4 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -9,7 +9,7 @@ from __future__ import absolute_import import warnings from .. import exc as sa_exc from .. import util - +import re def testing_warn(msg, stacklevel=3): """Replaces sqlalchemy.util.warn during tests.""" @@ -33,7 +33,7 @@ def resetwarnings(): warnings.filterwarnings('error', category=sa_exc.SAWarning) -def assert_warnings(fn, warnings): +def assert_warnings(fn, warnings, regex=False): """Assert that each of the given warnings are emitted by fn.""" from .assertions import eq_, emits_warning @@ -45,7 +45,10 @@ def assert_warnings(fn, warnings): orig_warn(*args, **kw) popwarn = warnings.pop(0) canary.append(popwarn) - eq_(args[0], popwarn) + if regex: + assert re.match(popwarn, args[0]) + else: + eq_(args[0], popwarn) util.warn = util.langhelpers.warn = capture_warnings result = emits_warning()(fn)() |