'When used in combination with a ``with`` statement this opens a
session transaction.  This can be used to modify the session that
the test client uses.  Once the ``with`` block is left the session is
stored back.
with client.session_transaction() as session:
session[\'value\'] = 42
Internally this is implemented by going through a temporary test
request context and since session handling could depend on
request variables this function accepts the same arguments as
:meth:`~flask.Flask.test_request_context` which are directly
passed through.'

@contextmanager
def session_transaction(self, *args, **kwargs):

    if (self.cookie_jar is None):
        raise RuntimeError('Session    transactions    only    make    sense    with    cookies    enabled.')
    app = self.application
    environ_overrides = kwargs.setdefault('environ_overrides', {})
    self.cookie_jar.inject_wsgi(environ_overrides)
    outer_reqctx = _request_ctx_stack.top
    with app.test_request_context(*args, **kwargs) as c:
        session_interface = app.session_interface
        sess = session_interface.open_session(app, c.request)
        if (sess is None):
            raise RuntimeError('Session    backend    did    not    open    a    session.    Check    the    configuration')
        _request_ctx_stack.push(outer_reqctx)
        try:
            (yield sess)
        finally:
            _request_ctx_stack.pop()
        resp = app.response_class()
        if (not session_interface.is_null_session(sess)):
            session_interface.save_session(app, sess, resp)
        headers = resp.get_wsgi_headers(c.request.environ)
        self.cookie_jar.extract_wsgi(c.request.environ, headers)
