update sqlalchemy

This commit is contained in:
Jan Gerber 2016-02-22 13:17:39 +01:00
commit a4267212e4
192 changed files with 17429 additions and 9601 deletions

View file

@ -1,5 +1,5 @@
# testing/warnings.py
# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2016 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@ -9,25 +9,11 @@ from __future__ import absolute_import
import warnings
from .. import exc as sa_exc
from .. import util
import re
from . import assertions
def testing_warn(msg, stacklevel=3):
"""Replaces sqlalchemy.util.warn during tests."""
filename = "sqlalchemy.testing.warnings"
lineno = 1
if isinstance(msg, util.string_types):
warnings.warn_explicit(msg, sa_exc.SAWarning, filename, lineno)
else:
warnings.warn_explicit(msg, filename, lineno)
def resetwarnings():
"""Reset warning behavior to testing defaults."""
util.warn = util.langhelpers.warn = testing_warn
def setup_filters():
"""Set global warning behavior for the test suite."""
warnings.filterwarnings('ignore',
category=sa_exc.SAPendingDeprecationWarning)
@ -35,24 +21,14 @@ def resetwarnings():
warnings.filterwarnings('error', category=sa_exc.SAWarning)
def assert_warnings(fn, warnings, regex=False):
"""Assert that each of the given warnings are emitted by fn."""
def assert_warnings(fn, warning_msgs, regex=False):
"""Assert that each of the given warnings are emitted by fn.
from .assertions import eq_, emits_warning
Deprecated. Please use assertions.expect_warnings().
canary = []
orig_warn = util.warn
"""
def capture_warnings(*args, **kw):
orig_warn(*args, **kw)
popwarn = warnings.pop(0)
canary.append(popwarn)
if regex:
assert re.match(popwarn, args[0])
else:
eq_(args[0], popwarn)
util.warn = util.langhelpers.warn = capture_warnings
with assertions._expect_warnings(
sa_exc.SAWarning, warning_msgs, regex=regex):
return fn()
result = emits_warning()(fn)()
assert canary, "No warning was emitted"
return result