test_cookies.py 文件源码

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

项目:annotated-py-sanic 作者: hhstore 项目源码 文件源码
def test_cookie_options():
    app = Sanic('test_text')

    @app.route('/')
    def handler(request):
        response = text("OK")
        response.cookies['test'] = 'at you'
        response.cookies['test']['httponly'] = True
        response.cookies['test']['expires'] = datetime.now() + timedelta(seconds=10)
        return response

    request, response = sanic_endpoint_test(app)
    response_cookies = SimpleCookie()
    response_cookies.load(response.headers.get('Set-Cookie', {}))

    assert response_cookies['test'].value == 'at you'
    assert response_cookies['test']['httponly'] == True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号