本文整理汇总了Python中fixture.SQLAlchemyFixture.dispose方法的典型用法代码示例。如果您正苦于以下问题:Python SQLAlchemyFixture.dispose方法的具体用法?Python SQLAlchemyFixture.dispose怎么用?Python SQLAlchemyFixture.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fixture.SQLAlchemyFixture
的用法示例。
在下文中一共展示了SQLAlchemyFixture.dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
# 需要导入模块: from fixture import SQLAlchemyFixture [as 别名]
# 或者: from fixture.SQLAlchemyFixture import dispose [as 别名]
def install(app, *args):
engine = m.create_tables(app)
db = SQLAlchemyFixture(env=m, style=NamedDataStyle(), engine=engine)
data = db.data(*args)
data.setup()
db.dispose()
return data
示例2: test_fixture_can_be_disposed
# 需要导入模块: from fixture import SQLAlchemyFixture [as 别名]
# 或者: from fixture.SQLAlchemyFixture import dispose [as 别名]
def test_fixture_can_be_disposed():
if sa_major < 0.5:
from sqlalchemy.exceptions import InvalidRequestError
else:
from sqlalchemy.exc import InvalidRequestError
engine = create_engine(conf.LITE_DSN)
metadata.bind = engine
metadata.create_all()
Session = get_transactional_session()
session = Session()
fixture = SQLAlchemyFixture(
env={'CategoryData':Category},
engine=metadata.bind
)
class CategoryData(DataSet):
class cars:
name = 'cars'
class free_stuff:
name = 'get free stuff'
clear_mappers()
mapper(Category, categories)
data = fixture.data(CategoryData)
data.setup()
data.teardown()
fixture.dispose()
# cannot use fixture anymore :
try:
data.setup()
except InvalidRequestError:
pass
else:
assert False, "data.setup() did not raise InvalidRequestError after connection was disposed"
# a new instance of everything is needed :
metadata.create_all()
fixture = SQLAlchemyFixture(
env={'CategoryData':Category},
engine=metadata.bind
)
data = fixture.data(CategoryData)
data.setup()
data.teardown()
示例3: install
# 需要导入模块: from fixture import SQLAlchemyFixture [as 别名]
# 或者: from fixture.SQLAlchemyFixture import dispose [as 别名]
def install(app, *args):
dbfixture = SQLAlchemyFixture(env=models, style=NamedDataStyle(),
engine=db.engine)
data = dbfixture.data(*args)
data.setup()
dbfixture.dispose()
示例4: install
# 需要导入模块: from fixture import SQLAlchemyFixture [as 别名]
# 或者: from fixture.SQLAlchemyFixture import dispose [as 别名]
def install(app, *args):
engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
db = SQLAlchemyFixture(env=models, style=NamedDataStyle(), engine=engine)
data = db.data(*args)
data.setup()
db.dispose()