当前位置: 首页>>代码示例>>Python>>正文


Python SQLAlchemyFixture.dispose方法代码示例

本文整理汇总了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
开发者ID:JohnBrodie,项目名称:whatup-api,代码行数:9,代码来源:__init__.py

示例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()
开发者ID:JamesX88,项目名称:tes,代码行数:49,代码来源:test_sqlalchemy_loadable.py

示例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()
开发者ID:seedofjoy,项目名称:library-example,代码行数:8,代码来源:fixtures.py

示例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()
开发者ID:Tutorspree,项目名称:minisync,代码行数:8,代码来源:fixtures.py


注:本文中的fixture.SQLAlchemyFixture.dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。