summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/warnings.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-02-19 12:01:48 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-02-19 12:01:48 -0500
commit140e8254a23c03f14d3f973e2ad3b197723007f8 (patch)
tree1a97071caf3e99c1fcd9a1b6674771348126eb3a /lib/sqlalchemy/testing/warnings.py
parent145db3bed7464e920cf2bb714cdf7672a1693eb3 (diff)
downloadsqlalchemy-140e8254a23c03f14d3f973e2ad3b197723007f8.tar.gz
- expect_warnings was not expecting and neither was assert_warnings
asserting.
Diffstat (limited to 'lib/sqlalchemy/testing/warnings.py')
-rw-r--r--lib/sqlalchemy/testing/warnings.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 47f1e1404..640f02a78 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
-import re
+from . import assertions
def setup_filters():
@@ -22,19 +22,13 @@ def setup_filters():
def assert_warnings(fn, warning_msgs, regex=False):
- """Assert that each of the given warnings are emitted by fn."""
-
- from .assertions import eq_
-
- with warnings.catch_warnings(record=True) as log:
- # ensure that nothing is going into __warningregistry__
- warnings.filterwarnings("always")
-
- result = fn()
- for warning in log:
- popwarn = warning_msgs.pop(0)
- if regex:
- assert re.match(popwarn, str(warning.message))
- else:
- eq_(popwarn, str(warning.message))
- return result
+ """Assert that each of the given warnings are emitted by fn.
+
+ Deprecated. Please use assertions.expect_warnings().
+
+ """
+
+ with assertions._expect_warnings(
+ sa_exc.SAWarning, warning_msgs, regex=regex):
+ return fn()
+