From 99c2defb431642f36d6869ff84922dced06c158a Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 10 Jul 2011 13:34:21 +0200 Subject: [PATCH] Added an example of how to postprocess requests in the testing docs. --- docs/testing.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/testing.rst b/docs/testing.rst index a196e2b7..098e81be 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -236,6 +236,20 @@ need to call :meth:`~flask.Flask.preprocess_request` yourself:: This can be necessary to open database connections or something similar depending on how your application was designed. +If you want to call the :meth:`~flask.Flask.after_request` functions you +need to call into :meth:`~flask.Flask.process_response` which however +requires that you pass it a response object:: + + app = flask.Flask(__name__) + + with app.test_request_context('/?name=Peter'): + resp = Response('...') + resp = app.process_response(resp) + ... + +This in general is less useful because at that point you can directly +start using the test client. + Keeping the Context Around --------------------------