test_aiohttp_validate.py 文件源码

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

项目:aiohttp_validate 作者: dchaplinsky 项目源码 文件源码
def test_invalid_request(test_client, loop):
    app = web.Application(loop=loop)
    app.router.add_post('/', hello)
    app.router.add_get('/', hello)
    client = await test_client(app)

    resp = await client.get('/')
    assert resp.status == 400
    text = await resp.json()
    assert 'Request is malformed' in text["error"]

    resp = await client.post('/')
    assert resp.status == 400
    text = await resp.json()
    assert 'Request is malformed' in text["error"]

    resp = await client.post('/', data="123afasdf")
    assert resp.status == 400
    text = await resp.json()
    assert 'Request is malformed' in text["error"]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号