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


Python DummyRequest.render方法代码示例

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


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

示例1: do_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import render [as 别名]
def do_request(resource, t=None, method="GET"):
    req = DummyRequest([])
    req.method = method
    req.args = {}
    if t:
        req.args["t"] = [t]
    req.render(resource)
    return "".join(req.written), req
开发者ID:warner,项目名称:petmail,代码行数:10,代码来源:test_server.py

示例2: make_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import render [as 别名]
def make_request(uri='', method='GET', args={}):
    site = make_site(authenticator=Mock())
    request = DummyRequest(uri.split('/'))
    request.method = method
    request.args = args
    resource = site.getResourceFor(request)
    request.render(resource)
    request.data = "".join(request.written)
    return request
开发者ID:shyba,项目名称:cryptosync,代码行数:11,代码来源:test_webserver.py

示例3: test_renderQuotesDigest

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import render [as 别名]
 def test_renderQuotesDigest(self):
     """
     The digest value must be correctly quoted.
     It is a byte string in python3, so we must make sure the proper conversion is done
     """
     resource = UnauthorizedResource([
             digest.DigestCredentialFactory(b'md5', b'example\\"foo')])
     request = DummyRequest([b''])
     request.render(resource)
     auth_header = request.responseHeaders.getRawHeaders(b'www-authenticate')[0]
     self.assertIn(b'realm="example\\\\\\"foo"', auth_header)
     self.assertIn(b'hm="md5', auth_header)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:14,代码来源:test_httpauth.py

示例4: test_renderQuotesRealm

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import render [as 别名]
 def test_renderQuotesRealm(self):
     """
     The realm value included in the I{WWW-Authenticate} header set in
     the response when L{UnauthorizedResounrce} is rendered has quotes
     and backslashes escaped.
     """
     resource = UnauthorizedResource([
             BasicCredentialFactory('example\\"foo')])
     request = DummyRequest([''])
     request.render(resource)
     self.assertEqual(
         request.responseHeaders.getRawHeaders('www-authenticate'),
         ['basic realm="example\\\\\\"foo"'])
开发者ID:jxta,项目名称:cc,代码行数:15,代码来源:test_httpauth.py

示例5: test_render

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import render [as 别名]
 def test_render(self):
     """
     L{UnauthorizedResource} renders with a 401 response code and a
     I{WWW-Authenticate} header and puts a simple unauthorized message
     into the response body.
     """
     resource = UnauthorizedResource([
             BasicCredentialFactory('example.com')])
     request = DummyRequest([''])
     request.render(resource)
     self.assertEqual(request.responseCode, 401)
     self.assertEqual(
         request.responseHeaders.getRawHeaders('www-authenticate'),
         ['basic realm="example.com"'])
     self.assertEqual(request.written, ['Unauthorized'])
开发者ID:jxta,项目名称:cc,代码行数:17,代码来源:test_httpauth.py


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