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


Python DummyChannel.site方法代码示例

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


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

示例1: renderResource

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
 def renderResource(self, resource, path):
     s = appserver.NevowSite(resource)
     channel = DummyChannel()
     channel.site = s
     r = appserver.NevowRequest(channel, True)
     r.path = path
     return r.process()
开发者ID:mithrandi,项目名称:nevow,代码行数:9,代码来源:test_appserver.py

示例2: create_request

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
 def create_request(self):
     channel = DummyChannel()
     channel.site = PixelatedSite(MagicMock())
     request = PixelatedSite.requestFactory(channel=channel, queued=True)
     request.method = "GET"
     request.uri = "localhost"
     request.clientproto = 'HTTP/1.1'
     request.prepath = []
     request.postpath = request.uri.split('/')[1:]
     request.path = "/"
     return request
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:13,代码来源:test_site.py

示例3: getTextOfPage

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def getTextOfPage(root, page, args=None, return_request=False):
    """This perpetrates several awful hacks."""
    if args is not None:
        page += '?' + urllib.urlencode(args)
    channel = DummyChannel()
    channel.site = Site(root)
    r = Request(channel, 0)
    r.content = StringIO()
    r.requestReceived("GET", "/" + page, "1.1")
    if return_request:
        return channel.transport.written.getvalue(), r
    else:
        return channel.transport.written.getvalue()
开发者ID:chevah,项目名称:pydoctor,代码行数:15,代码来源:test_server.py

示例4: test_renderPOST

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
    def test_renderPOST(self):
        """
        A POST request with form data has the form data parsed into
        C{request.fields}.
        """
        class Res(Render):
            def renderHTTP(self, ctx):
                return b''

        s = appserver.NevowSite(Res())
        channel = DummyChannel()
        channel.site = s
        r = appserver.NevowRequest(channel, True)
        r.method = b'POST'
        r.path = b'/'
        r.content = StringIO(b'foo=bar')
        self.successResultOf(r.process())
        self.assertEquals(r.fields[b'foo'].value, b'bar')
开发者ID:twisted,项目名称:nevow,代码行数:20,代码来源:test_appserver.py

示例5: test_connectionLost

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
    def test_connectionLost(self):
        """
        L{Request.finish} is not called when the connection is lost before
        rendering has finished.
        """
        rendering = Deferred()
        class Res(Render):
            def renderHTTP(self, ctx):
                return rendering
        site = appserver.NevowSite(Res())
        channel = DummyChannel()
        channel.site = site
        request = appserver.NevowRequest(channel, True)
        request.connectionLost(Exception("Just Testing"))
        rendering.callback(b"finished")

        self.assertFalse(
            request.finished, "Request was incorrectly marked as finished.")
开发者ID:twisted,项目名称:nevow,代码行数:20,代码来源:test_appserver.py

示例6: renderResourceReturnTransport

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def renderResourceReturnTransport(resource, path, method):
    """
    Perform a synthetic request for the given resource.  This is like
    L{renderResource} but with a different return value.

    @return: All of the bytes written to the transport as a result of the
        rendering.
    """
    s = appserver.NevowSite(resource)
    channel = DummyChannel()
    channel.site = s
    r = appserver.NevowRequest(channel, True)
    r.path = path
    if method is not None:
        r.method = method
    d = r.process()
    d.addCallback(lambda ignored: channel.transport.written.getvalue())
    return d
开发者ID:twisted,项目名称:nevow,代码行数:20,代码来源:test_appserver.py

示例7: renderResource

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def renderResource(resource, path, method=None):
    """
    Perform a synthetic request for the given resource.

    @param resource: The L{nevow.inevow.IResource} from which to begin
        processing.

    @param path: The path of the url to use in processing.

    @param method: An optional request method to use.

    @return: The return value of L{NevowRequest.process} for this resource,
        path, and method.
    """
    s = appserver.NevowSite(resource)
    channel = DummyChannel()
    channel.site = s
    r = appserver.NevowRequest(channel, True)
    r.path = path
    if method is not None:
        r.method = method
    return r.process()
开发者ID:twisted,项目名称:nevow,代码行数:24,代码来源:test_appserver.py

示例8: createServer

# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
 def createServer(self, r):
     chan = DummyChannel()
     chan.site = server.Site(r)
     return chan
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:6,代码来源:test_web.py


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