本文整理汇总了Python中sqlalchemy.testing.provide_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python testing.provide_metadata方法的具体用法?Python testing.provide_metadata怎么用?Python testing.provide_metadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.testing
的用法示例。
在下文中一共展示了testing.provide_metadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connection
# 需要导入模块: from sqlalchemy import testing [as 别名]
# 或者: from sqlalchemy.testing import provide_metadata [as 别名]
def connection(self):
eng = getattr(self, "bind", config.db)
conn = eng.connect()
trans = conn.begin()
try:
yield conn
finally:
if trans.is_active:
trans.rollback()
conn.close()
# propose a replacement for @testing.provide_metadata.
# the problem with this is that TablesTest below has a ".metadata"
# attribute already which is accessed directly as part of the
# @testing.provide_metadata pattern. Might need to call this _metadata
# for it to be useful.
# @config.fixture()
# def metadata(self):
# """Provide bound MetaData for a single test, dropping afterwards."""
#
# from . import engines
# metadata = schema.MetaData(config.db)
# try:
# yield metadata
# finally:
# engines.drop_all_tables(metadata, config.db)