本文整理匯總了Python中sqlalchemy.testing.fixtures.TestBase方法的典型用法代碼示例。如果您正苦於以下問題:Python fixtures.TestBase方法的具體用法?Python fixtures.TestBase怎麽用?Python fixtures.TestBase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.testing.fixtures
的用法示例。
在下文中一共展示了fixtures.TestBase方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: want_class
# 需要導入模塊: from sqlalchemy.testing import fixtures [as 別名]
# 或者: from sqlalchemy.testing.fixtures import TestBase [as 別名]
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
示例2: test_columns_single_inheritance_cascading_resolution_pk
# 需要導入模塊: from sqlalchemy.testing import fixtures [as 別名]
# 或者: from sqlalchemy.testing.fixtures import TestBase [as 別名]
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)
示例3: startContext
# 需要導入模塊: from sqlalchemy.testing import fixtures [as 別名]
# 或者: from sqlalchemy.testing.fixtures import TestBase [as 別名]
def startContext(self, ctx):
if not isinstance(ctx, type) \
or not issubclass(ctx, fixtures.TestBase):
return
plugin_base.start_test_class(ctx)
示例4: stopContext
# 需要導入模塊: from sqlalchemy.testing import fixtures [as 別名]
# 或者: from sqlalchemy.testing.fixtures import TestBase [as 別名]
def stopContext(self, ctx):
if not isinstance(ctx, type) \
or not issubclass(ctx, fixtures.TestBase):
return
plugin_base.stop_test_class(ctx)