test_web_functional.py 文件源码

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

项目:aiohttp-tokio 作者: fafhrd91 项目源码 文件源码
def test_post_max_client_size(loop, test_client):

    @asyncio.coroutine
    def handler(request):
        try:
            yield from request.post()
        except ValueError:
            return web.HTTPOk()
        return web.HTTPBadRequest()

    app = web.Application(client_max_size=10)
    app.router.add_post('/', handler)
    client = yield from test_client(app)

    data = {"long_string": 1024 * 'x', 'file': io.BytesIO(b'test')}
    resp = yield from client.post('/', data=data)

    assert 200 == resp.status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号