當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。