test_static.py 文件源码

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

项目:sanic 作者: channelcat 项目源码 文件源码
def test_static_content_range_back(file_name, static_file_directory):
    app = Sanic('test_static')
    app.static(
        '/testing.file', get_file_path(static_file_directory, file_name),
        use_content_range=True)

    headers = {
        'Range': 'bytes=-12'
    }
    request, response = app.test_client.get('/testing.file', headers=headers)
    assert response.status == 200
    assert 'Content-Length' in response.headers
    assert 'Content-Range' in response.headers
    static_content = bytes(get_file_content(
        static_file_directory, file_name))[-12:]
    assert int(response.headers[
               'Content-Length']) == len(static_content)
    assert response.body == static_content
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号