summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-11-25 15:15:35 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-11-25 15:15:35 -0500
commit2a2be6a2ce66ed1040c0345a20f959cbea218859 (patch)
treee934cabfbeef370c98ff0c9be187fc7cadd410e5
parent2743b674f5f9cd0aa3a9f135cbe75607cd63a7d9 (diff)
downloadsqlalchemy-2a2be6a2ce66ed1040c0345a20f959cbea218859.tar.gz
- support declarativemappedtest with per-test setup
-rw-r--r--lib/sqlalchemy/testing/fixtures.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index e16bc77c0..5cd0244ef 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -275,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
@@ -302,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
@@ -336,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