From 00c6ebb4408964583943826c831064e1d7472169 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 16 Feb 2014 18:14:10 -0500 Subject: - rewrite SQLite reflection tests into one consistent fixture, which tests both _resolve_type_affinity() directly as well as round trip tests fully. --- lib/sqlalchemy/testing/warnings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/testing') 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)() -- cgit v1.2.1