diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-29 17:47:59 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-29 17:47:59 -0500 |
| commit | 0536c48dafb670d34fc96d26078b41ed6accf01f (patch) | |
| tree | b3109ed91ac61e5ddbe8c77c5a1e0bf3e08c0f51 /test/lib | |
| parent | cd655cf0996de682365201a0184170256da6859b (diff) | |
| download | sqlalchemy-0536c48dafb670d34fc96d26078b41ed6accf01f.tar.gz | |
- expand the check to determine if a selectable column is embedded
in the corresponding selectable to take into account clones
of the target column. fixes [ticket:2419]
- have _make_proxy() copy out the _is_clone_of attribute on the
new column so that even more corresponding_column() checks
work as expected for cloned elements.
- add a new test fixture so that mapped tests can be specified
using declarative.
Diffstat (limited to 'test/lib')
| -rw-r--r-- | test/lib/fixtures.py | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/test/lib/fixtures.py b/test/lib/fixtures.py index 6714107bd..03116fbc1 100644 --- a/test/lib/fixtures.py +++ b/test/lib/fixtures.py @@ -4,6 +4,7 @@ from test.lib.engines import drop_all_tables import sys import sqlalchemy as sa from test.lib.entities import BasicEntity, ComparableEntity +from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta class TestBase(object): # A sequence of database names to always run, regardless of the @@ -228,8 +229,7 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): @classmethod def teardown_class(cls): - cls.classes.clear() - _ORMTest.teardown_class() + cls._teardown_once_class() cls._teardown_once_metadata_bind() def setup(self): @@ -243,6 +243,12 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): self._teardown_each_tables() @classmethod + def _teardown_once_class(cls): + cls.classes.clear() + _ORMTest.teardown_class() + + + @classmethod def _setup_once_classes(cls): if cls.run_setup_classes == 'once': cls._with_register_classes(cls.setup_classes) @@ -269,6 +275,7 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): cls_registry[classname] = cls return type.__init__(cls, classname, bases, dict_) + class _Base(object): __metaclass__ = FindFixture class Basic(BasicEntity, _Base): @@ -294,3 +301,35 @@ class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): def setup_mappers(cls): pass +class DeclarativeMappedTest(MappedTest): + declarative_meta = None + + @classmethod + def setup_class(cls): + if cls.declarative_meta is None: + cls.declarative_meta = sa.MetaData() + + super(DeclarativeMappedTest, cls).setup_class() + + @classmethod + def _teardown_once_class(cls): + if cls.declarative_meta.tables: + cls.declarative_meta.drop_all(testing.db) + super(DeclarativeMappedTest, cls)._teardown_once_class() + + @classmethod + def _with_register_classes(cls, fn): + cls_registry = cls.classes + class FindFixtureDeclarative(DeclarativeMeta): + def __init__(cls, classname, bases, dict_): + cls_registry[classname] = cls + return DeclarativeMeta.__init__( + cls, classname, bases, dict_) + _DeclBase = declarative_base(metadata=cls.declarative_meta, + metaclass=FindFixtureDeclarative) + class DeclarativeBasic(BasicEntity): + pass + cls.DeclarativeBasic = _DeclBase + fn() + if cls.declarative_meta.tables: + cls.declarative_meta.create_all(testing.db) |
