test_engine.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:sqlalchemy_aio 作者: RazerM 项目源码 文件源码
def test_implicit_transaction_failure(engine, mytable):
    await engine.execute(CreateTable(mytable))

    with pytest.raises(RuntimeError):
        async with engine.begin() as conn:
            assert isinstance(conn, AsyncioConnection)

            await conn.execute(mytable.insert())
            result = await conn.execute(mytable.select())
            rows = await result.fetchall()
            assert len(rows) == 1

            raise RuntimeError

    # Transaction should have been rolled back automatically
    result = await engine.execute(mytable.select())
    rows = await result.fetchall()
    assert len(rows) == 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号