summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/entities.py10
-rw-r--r--lib/sqlalchemy/testing/fixtures.py13
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/sqlalchemy/testing/entities.py b/lib/sqlalchemy/testing/entities.py
index f5d207bc2..085c19196 100644
--- a/lib/sqlalchemy/testing/entities.py
+++ b/lib/sqlalchemy/testing/entities.py
@@ -39,10 +39,7 @@ class BasicEntity(object):
_recursion_stack = set()
-class ComparableEntity(BasicEntity):
- def __hash__(self):
- return hash(self.__class__)
-
+class ComparableMixin(object):
def __ne__(self, other):
return not self.__eq__(other)
@@ -107,3 +104,8 @@ class ComparableEntity(BasicEntity):
return True
finally:
_recursion_stack.remove(id(self))
+
+
+class ComparableEntity(ComparableMixin, BasicEntity):
+ def __hash__(self):
+ return hash(self.__class__)
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index 85d3374de..2d3b27917 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -15,11 +15,13 @@ from . import schema
from .engines import drop_all_tables
from .entities import BasicEntity
from .entities import ComparableEntity
+from .entities import ComparableMixin # noqa
from .util import adict
from .. import event
from .. import util
-from ..ext.declarative import declarative_base
-from ..ext.declarative import DeclarativeMeta
+from ..orm import declarative_base
+from ..orm import registry
+from ..orm.decl_api import DeclarativeMeta
from ..schema import sort_tables_and_constraints
@@ -383,10 +385,12 @@ class MappedTest(_ORMTest, TablesTest, assertions.AssertsExecutionResults):
@classmethod
def _setup_once_mappers(cls):
if cls.run_setup_mappers == "once":
+ cls.mapper = cls._generate_mapper()
cls._with_register_classes(cls.setup_mappers)
def _setup_each_mappers(self):
if self.run_setup_mappers == "each":
+ self.mapper = self._generate_mapper()
self._with_register_classes(self.setup_mappers)
def _setup_each_classes(self):
@@ -394,6 +398,11 @@ class MappedTest(_ORMTest, TablesTest, assertions.AssertsExecutionResults):
self._with_register_classes(self.setup_classes)
@classmethod
+ def _generate_mapper(cls):
+ decl = registry()
+ return decl.map_imperatively
+
+ @classmethod
def _with_register_classes(cls, fn):
"""Run a setup method, framing the operation with a Base class
that will catch new subclasses to be established within