示例#1
0
async def sub_reset():
    assert is_local_root() is False
    assert get_local().get('val') == 123

    reset_local()
    assert is_local_root()
    assert get_local().get('val') is None

    get_local()['val'] = 456
    assert get_local().get('val') == 456
    await asyncio.ensure_future(grand_sub())

    reset_local()
    assert get_local().get('val') == 456
    await asyncio.ensure_future(grand_sub())
示例#2
0
async def test_inline_reset(task_local):
    get_local()['val'] = 123
    await asyncio.ensure_future(sub_reset())
    get_local()['val'] = 123
示例#3
0
async def sub(result):
    result.append(get_local().get('val'))
示例#4
0
async def grand_sub():
    assert not is_local_root()
    assert get_local().get('val') == 456
示例#5
0
async def test_detached_reverse(task_local):
    await reset_local(sub_set())
    assert get_local().get('val') is None
示例#6
0
async def test_accept_task(task_local):
    await reset_local(asyncio.ensure_future(sub_set()))
    assert get_local().get('val') is None
示例#7
0
async def test_attached_reverse(task_local):
    await asyncio.ensure_future(sub_set())
    assert get_local().get('val') == 123
示例#8
0
async def sub_set():
    get_local()['val'] = 123
示例#9
0
async def test_detached(task_local):
    get_local()['val'] = 123
    result = []
    await reset_local(sub(result))
    assert result[0] is None
示例#10
0
async def test_attached(task_local):
    get_local()['val'] = 123
    result = []
    await asyncio.ensure_future(sub(result))
    assert result[0] == 123
示例#11
0
async def test_issue_79(task_local):
    db = Gino()
    pool = await db.create_pool('postgresql:///non_exist', min_size=0)
    with pytest.raises(InvalidCatalogNameError):
        await pool.acquire()
    assert len(get_local().get('connection_stack', [])) == 0