From 5575faad92f69993e3823cd94044a2dd7796c82d Mon Sep 17 00:00:00 2001 From: Adam Byrtek Date: Mon, 6 Apr 2015 13:50:29 +0200 Subject: [PATCH] Update documentation to use the getter only once --- docs/testing.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/testing.rst b/docs/testing.rst index d8c3bac1..8b9af8bd 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -368,15 +368,17 @@ convenient: @app.route('/api/auth') def auth(): - email = request.get_json()['email'] - password = request.get_json()['password'] + json_data = request.get_json() + email = json_data['email'] + password = json_data['password'] return jsonify(token=generate_token(email, password)) with app.test_client() as c: email = 'john@example.com' password = 'secret' resp = c.post('/api/auth', json={'login': email, 'password': password}) - assert verify_token(email, resp.get_json()['token']) + json_data = resp.get_json() + assert verify_token(email, json_data['token']) Note that if the ``json`` argument is provided then the test client will put JSON-serialized data in the request body, and also set the