Python sqlalchemy.testing.fixtures.TestBase() Examples

The following are code examples for showing how to use sqlalchemy.testing.fixtures.TestBase(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: alembic   Author: sqlalchemy   File: plugin_base.py    MIT License 6 votes vote down vote up
def want_class(name, cls):
    from sqlalchemy.testing import config
    from sqlalchemy.testing import fixtures

    if not issubclass(cls, fixtures.TestBase):
        return False
    elif name.startswith("_"):
        return False
    elif (
        config.options.backend_only
        and not getattr(cls, "__backend__", False)
        and not getattr(cls, "__sparse_backend__", False)
    ):
        return False
    else:
        return True 
Example 2
Project: sqlalchemy   Author: sqlalchemy   File: test_inheritance.py    MIT License 5 votes vote down vote up
def test_columns_single_inheritance_cascading_resolution_pk(self):
        """An additional test for #4352 in terms of the requested use case.

        """

        class TestBase(Base):
            __abstract__ = True

            @declared_attr.cascading
            def id(cls):
                col_val = None
                if TestBase not in cls.__bases__:
                    col_val = cls.__table__.c.get("id")
                if col_val is None:
                    col_val = Column(Integer, primary_key=True)
                return col_val

        class Person(TestBase):
            """single table base class"""

            __tablename__ = "person"

        class Engineer(Person):
            """ single table inheritance, no extra cols """

        class Manager(Person):
            """ single table inheritance, no extra cols """

        is_(Engineer.id.property.columns[0], Person.__table__.c.id)
        is_(Manager.id.property.columns[0], Person.__table__.c.id)