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


Python test.run_wsgi_app方法代码示例

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


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

示例1: _run_wsgi_app

# 需要导入模块: from werkzeug import test [as 别名]
# 或者: from werkzeug.test import run_wsgi_app [as 别名]
def _run_wsgi_app(*args):
    """This function replaces itself to ensure that the test module is not
    imported unless required.  DO NOT USE!
    """
    global _run_wsgi_app
    from werkzeug.test import run_wsgi_app as _run_wsgi_app
    return _run_wsgi_app(*args) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:wrappers.py

示例2: force_type

# 需要导入模块: from werkzeug import test [as 别名]
# 或者: from werkzeug.test import run_wsgi_app [as 别名]
def force_type(cls, response, environ=None):
        """Enforce that the WSGI response is a response object of the current
        type.  Werkzeug will use the :class:`BaseResponse` internally in many
        situations like the exceptions.  If you call :meth:`get_response` on an
        exception you will get back a regular :class:`BaseResponse` object, even
        if you are using a custom subclass.

        This method can enforce a given response type, and it will also
        convert arbitrary WSGI callables into response objects if an environ
        is provided::

            # convert a Werkzeug response object into an instance of the
            # MyResponseClass subclass.
            response = MyResponseClass.force_type(response)

            # convert any WSGI application into a response object
            response = MyResponseClass.force_type(response, environ)

        This is especially useful if you want to post-process responses in
        the main dispatcher and use functionality provided by your subclass.

        Keep in mind that this will modify response objects in place if
        possible!

        :param response: a response object or wsgi application.
        :param environ: a WSGI environment object.
        :return: a response object.
        """
        if not isinstance(response, BaseResponse):
            if environ is None:
                raise TypeError('cannot convert WSGI application into '
                                'response objects without an environ')
            response = BaseResponse(*_run_wsgi_app(response, environ))
        response.__class__ = cls
        return response 
开发者ID:jpush,项目名称:jbox,代码行数:37,代码来源:wrappers.py

示例3: from_app

# 需要导入模块: from werkzeug import test [as 别名]
# 或者: from werkzeug.test import run_wsgi_app [as 别名]
def from_app(cls, app, environ, buffered=False):
        """Create a new response object from an application output.  This
        works best if you pass it an application that returns a generator all
        the time.  Sometimes applications may use the `write()` callable
        returned by the `start_response` function.  This tries to resolve such
        edge cases automatically.  But if you don't get the expected output
        you should set `buffered` to `True` which enforces buffering.

        :param app: the WSGI application to execute.
        :param environ: the WSGI environment to execute against.
        :param buffered: set to `True` to enforce buffering.
        :return: a response object.
        """
        return cls(*_run_wsgi_app(app, environ, buffered)) 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:wrappers.py


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