Python flask.testing 模块,FlaskClient() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用flask.testing.FlaskClient()

项目:annotated-py-flask    作者:hhstore    | 项目源码 | 文件源码
def test_client(self):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.
        """
        from flask.testing import FlaskClient
        return FlaskClient(self, self.response_class, use_cookies=True)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Texty    作者:sarthfrey    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:arithmancer    作者:google    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:tesismometro    作者:joapaspe    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Indushell    作者:SecarmaLabs    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:flask_system    作者:prashasy    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:osp-api    作者:opensyllabus    | 项目源码 | 文件源码
def setup_client(before_create_app: Callable = None) -> FlaskClient:
    """Create and return the testing client.

    Arguments:
        before_create_app: A function which will be called before the
            Flask app is created. Originally implemented to support
            creating resources for testing.

    """

    # We need a secret key for JWT to work!
    config.SECRET_KEY = 'loltestingkey'

    # We don't wanna use redis for testing (too much of a hassle)
    config.FLASK_CACHE['CACHE_TYPE'] = 'simple'
    config.TESTING = True
    config.RATELIMIT_STORAGE_URL = 'memory://'

    # We'll be using unauthed/free a lot
    RATELIMIT_DEFAULT = config.RATELIMIT_DEFAULT_FREE
    config.RATELIMIT_DEFAULT = '2000 per minute'

    if before_create_app:
        before_create_app()

    app = create_app()
    client = app.test_client()
    with app.app_context():
        users.create_db_and_default_roles()
        users.create_dummy_users()

    return client
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:tellmeabout.coffee    作者:billyfung    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:PornGuys    作者:followloda    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:jieba-GAE    作者:liantian-cn    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:goulash-bot    作者:damdev    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:QA4LOV    作者:gatemezing    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:Flask-SocketIO    作者:cutedogspark    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:compatify    作者:hatooku    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:compatify    作者:hatooku    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:hate-to-hugs    作者:sdoran35    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:ropi    作者:ThumbGen    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:skojjt    作者:martin-green    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:zoom-autocomplete-demo    作者:kenju254    | 项目源码 | 文件源码
def test_client(self, use_cookies=True):
        """Creates a test client for this application.  For information
        about unit testing head over to :ref:`testing`.

        Note that if you are testing for assertions or exceptions in your
        application code, you must set ``app.testing = True`` in order for the
        exceptions to propagate to the test client.  Otherwise, the exception
        will be handled by the application (not visible to the test client) and
        the only indication of an AssertionError or other exception will be a
        500 status code response to the test client.  See the :attr:`testing`
        attribute.  For example::

            app.testing = True
            client = app.test_client()

        The test client can be used in a `with` block to defer the closing down
        of the context until the end of the `with` block.  This is useful if
        you want to access the context locals for testing::

            with app.test_client() as c:
                rv = c.get('/?vodka=42')
                assert request.args['vodka'] == '42'

        See :class:`~flask.testing.FlaskClient` for more information.

        .. versionchanged:: 0.4
           added support for `with` block usage for the client.

        .. versionadded:: 0.7
           The `use_cookies` parameter was added as well as the ability
           to override the client to be used by setting the
           :attr:`test_client_class` attribute.
        """
        cls = self.test_client_class
        if cls is None:
            from flask.testing import FlaskClient as cls
        return cls(self, self.response_class, use_cookies=use_cookies)
项目:ieee-cs-txst    作者:codestar12    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))
项目:pillar    作者:armadillica    | 项目源码 | 文件源码
def setUp(self, **kwargs):
        eve_settings_file = os.path.join(MY_PATH, 'eve_test_settings.py')
        kwargs['settings_file'] = eve_settings_file
        os.environ['EVE_SETTINGS'] = eve_settings_file
        super(AbstractPillarTest, self).setUp(**kwargs)

        from eve.utils import config
        config.DEBUG = True

        self.app = self.pillar_server_class(pathlib.Path(__file__).parents[2])
        self.assertEqual(self.app.config['STORAGE_DIR'], self._pillar_storage_dir)

        # Run self.enter_app_context() to create this context.
        self._app_ctx: flask.ctx.AppContext = None

        self.app.process_extensions()
        assert self.app.config['MONGO_DBNAME'] == 'pillar_test'

        self.client = self.app.test_client()
        assert isinstance(self.client, FlaskClient)
项目:sam-s-club-auctions    作者:sameer2800    | 项目源码 | 文件源码
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            for cls in exc_class.__mro__:
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code))