update sqlalchemy
This commit is contained in:
parent
6c6c3e68c6
commit
a4267212e4
192 changed files with 17429 additions and 9601 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# testing/fixtures.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
|
||||
|
|
@ -91,20 +91,12 @@ class TablesTest(TestBase):
|
|||
cls.run_create_tables = 'each'
|
||||
assert cls.run_inserts in ('each', None)
|
||||
|
||||
if cls.other is None:
|
||||
cls.other = adict()
|
||||
cls.other = adict()
|
||||
cls.tables = adict()
|
||||
|
||||
if cls.tables is None:
|
||||
cls.tables = adict()
|
||||
|
||||
if cls.bind is None:
|
||||
setattr(cls, 'bind', cls.setup_bind())
|
||||
|
||||
if cls.metadata is None:
|
||||
setattr(cls, 'metadata', sa.MetaData())
|
||||
|
||||
if cls.metadata.bind is None:
|
||||
cls.metadata.bind = cls.bind
|
||||
cls.bind = cls.setup_bind()
|
||||
cls.metadata = sa.MetaData()
|
||||
cls.metadata.bind = cls.bind
|
||||
|
||||
@classmethod
|
||||
def _setup_once_inserts(cls):
|
||||
|
|
@ -142,13 +134,14 @@ class TablesTest(TestBase):
|
|||
def _teardown_each_tables(self):
|
||||
# no need to run deletes if tables are recreated on setup
|
||||
if self.run_define_tables != 'each' and self.run_deletes == 'each':
|
||||
for table in reversed(self.metadata.sorted_tables):
|
||||
try:
|
||||
table.delete().execute().close()
|
||||
except sa.exc.DBAPIError as ex:
|
||||
util.print_(
|
||||
("Error emptying table %s: %r" % (table, ex)),
|
||||
file=sys.stderr)
|
||||
with self.bind.connect() as conn:
|
||||
for table in reversed(self.metadata.sorted_tables):
|
||||
try:
|
||||
conn.execute(table.delete())
|
||||
except sa.exc.DBAPIError as ex:
|
||||
util.print_(
|
||||
("Error emptying table %s: %r" % (table, ex)),
|
||||
file=sys.stderr)
|
||||
|
||||
def setup(self):
|
||||
self._setup_each_tables()
|
||||
|
|
@ -200,9 +193,8 @@ class TablesTest(TestBase):
|
|||
def sql_count_(self, count, fn):
|
||||
self.assert_sql_count(self.bind, fn, count)
|
||||
|
||||
def sql_eq_(self, callable_, statements, with_sequences=None):
|
||||
self.assert_sql(self.bind,
|
||||
callable_, statements, with_sequences)
|
||||
def sql_eq_(self, callable_, statements):
|
||||
self.assert_sql(self.bind, callable_, statements)
|
||||
|
||||
@classmethod
|
||||
def _load_fixtures(cls):
|
||||
|
|
@ -283,12 +275,14 @@ class MappedTest(_ORMTest, TablesTest, assertions.AssertsExecutionResults):
|
|||
|
||||
def setup(self):
|
||||
self._setup_each_tables()
|
||||
self._setup_each_classes()
|
||||
self._setup_each_mappers()
|
||||
self._setup_each_inserts()
|
||||
|
||||
def teardown(self):
|
||||
sa.orm.session.Session.close_all()
|
||||
self._teardown_each_mappers()
|
||||
self._teardown_each_classes()
|
||||
self._teardown_each_tables()
|
||||
|
||||
@classmethod
|
||||
|
|
@ -310,6 +304,10 @@ class MappedTest(_ORMTest, TablesTest, assertions.AssertsExecutionResults):
|
|||
if self.run_setup_mappers == 'each':
|
||||
self._with_register_classes(self.setup_mappers)
|
||||
|
||||
def _setup_each_classes(self):
|
||||
if self.run_setup_classes == 'each':
|
||||
self._with_register_classes(self.setup_classes)
|
||||
|
||||
@classmethod
|
||||
def _with_register_classes(cls, fn):
|
||||
"""Run a setup method, framing the operation with a Base class
|
||||
|
|
@ -344,6 +342,10 @@ class MappedTest(_ORMTest, TablesTest, assertions.AssertsExecutionResults):
|
|||
if self.run_setup_mappers != 'once':
|
||||
sa.orm.clear_mappers()
|
||||
|
||||
def _teardown_each_classes(self):
|
||||
if self.run_setup_classes != 'once':
|
||||
self.classes.clear()
|
||||
|
||||
@classmethod
|
||||
def setup_classes(cls):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue