当前位置: 首页>>代码示例>>Python>>正文


Python Response.merge_cookies方法代码示例

本文整理汇总了Python中webob.response.Response.merge_cookies方法的典型用法代码示例。如果您正苦于以下问题:Python Response.merge_cookies方法的具体用法?Python Response.merge_cookies怎么用?Python Response.merge_cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webob.response.Response的用法示例。

在下文中一共展示了Response.merge_cookies方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_cookies

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_cookies():
    res = Response()
    # test unicode value
    res.set_cookie("x", "test")
    # utf8 encoded
    eq_(res.headers.getall("set-cookie"), ["x=test; Path=/"])
    r2 = res.merge_cookies(simple_app)
    r2 = BaseRequest.blank("/").get_response(r2)
    eq_(r2.headerlist, [("Content-Type", "text/html; charset=utf8"), ("Set-Cookie", "x=test; Path=/")])
开发者ID:ckey,项目名称:webob,代码行数:11,代码来源:test_response.py


示例2: test_cookies

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_cookies():
    res = Response()
    # test unicode value
    res.set_cookie("x", text_(b"\N{BLACK SQUARE}", "unicode_escape"))
    # utf8 encoded
    eq_(res.headers.getall("set-cookie"), ['x="\\342\\226\\240"; Path=/'])
    r2 = res.merge_cookies(simple_app)
    r2 = BaseRequest.blank("/").get_response(r2)
    eq_(r2.headerlist, [("Content-Type", "text/html; charset=utf8"), ("Set-Cookie", 'x="\\342\\226\\240"; Path=/')])
开发者ID:xpahos,项目名称:webob,代码行数:11,代码来源:test_response.py


示例3: test_cookies

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_cookies():
    res = Response()
    # test unicode value
    res.set_cookie('x', "test")
    # utf8 encoded
    assert res.headers.getall('set-cookie') == ['x=test; Path=/']
    r2 = res.merge_cookies(simple_app)
    r2 = BaseRequest.blank('/').get_response(r2)
    assert r2.headerlist == [
        ('Content-Type', 'text/html; charset=utf8'),
        ('Set-Cookie', 'x=test; Path=/'),
        ]
开发者ID:doulbekill,项目名称:webob,代码行数:14,代码来源:test_response.py


示例4: test_cookies

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_cookies():
    res = Response()
    # test unicode value
    res.set_cookie('x', text_(b'\N{BLACK SQUARE}', 'unicode_escape'))
    # utf8 encoded
    eq_(res.headers.getall('set-cookie'), ['x="\\342\\226\\240"; Path=/'])
    r2 = res.merge_cookies(simple_app)
    r2 = BaseRequest.blank('/').get_response(r2)
    eq_(r2.headerlist,
        [('Content-Type', 'text/html; charset=utf8'),
        ('Set-Cookie', 'x="\\342\\226\\240"; Path=/'),
        ]
    )
开发者ID:MiCHiLU,项目名称:webob,代码行数:15,代码来源:test_response.py


示例5: test_merge_cookies_resp_is_wsgi_callable

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_merge_cookies_resp_is_wsgi_callable():
    L = []
    def dummy_wsgi_callable(environ, start_response):
        L.append((environ, start_response))
        return 'abc'
    res = Response()
    res.set_cookie('a', '1')
    wsgiapp = res.merge_cookies(dummy_wsgi_callable)
    environ = {}
    def dummy_start_response(status, headers, exc_info=None):
        assert headers, [('Set-Cookie' == 'a=1; Path=/')]
    result = wsgiapp(environ, dummy_start_response)
    assert result == 'abc'
    assert len(L) == 1
    L[0][1]('200 OK', []) # invoke dummy_start_response assertion
开发者ID:doulbekill,项目名称:webob,代码行数:17,代码来源:test_response.py


示例6: test_merge_cookies_resp_is_wsgi_callable

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_merge_cookies_resp_is_wsgi_callable():
    L = []

    def dummy_wsgi_callable(environ, start_response):
        L.append((environ, start_response))
        return "abc"

    res = Response()
    res.set_cookie("a", "1")
    wsgiapp = res.merge_cookies(dummy_wsgi_callable)
    environ = {}

    def dummy_start_response(status, headers, exc_info=None):
        assert headers, [("Set-Cookie" == "a=1; Path=/")]

    result = wsgiapp(environ, dummy_start_response)
    assert result == "abc"
    assert len(L) == 1
    L[0][1]("200 OK", [])  # invoke dummy_start_response assertion
开发者ID:Pylons,项目名称:webob,代码行数:21,代码来源:test_response.py


示例7: test_merge_cookies_resp_is_Response

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_merge_cookies_resp_is_Response():
    inner_res = Response()
    res = Response()
    res.set_cookie('a', '1')
    result = res.merge_cookies(inner_res)
    assert result.headers.getall('Set-Cookie') == ['a=1; Path=/']
开发者ID:doulbekill,项目名称:webob,代码行数:8,代码来源:test_response.py


示例8: test_merge_cookies_no_set_cookie

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_merge_cookies_no_set_cookie():
    res = Response()
    result = res.merge_cookies('abc')
    assert result == 'abc'
开发者ID:doulbekill,项目名称:webob,代码行数:6,代码来源:test_response.py


示例9: test_merge_cookies_no_set_cookie

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import merge_cookies [as 别名]
def test_merge_cookies_no_set_cookie():
    res = Response()
    result = res.merge_cookies('abc')
    eq_(result, 'abc')
开发者ID:perey,项目名称:webob,代码行数:6,代码来源:test_response.py



注:本文中的webob.response.Response.merge_cookies方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。