本文整理匯總了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)