Complete the code to import the Flask testing client.
from flask import Flask app = Flask(__name__) client = app.[1]()
The test_client() method creates a testing client to simulate requests to the Flask app.
Complete the code to check the response status code in a test.
response = client.get('/') assert response.[1] == 200
The status_code attribute holds the HTTP status code returned by the server.
Fix the error in the test function to use the correct Flask test client method.
def test_homepage(): response = client.[1]('/home') assert response.status_code == 200
The get method is used to simulate a GET request in Flask tests.
Fill both blanks to create a test that posts JSON data and checks the response.
response = client.[1]('/submit', json=[2]) assert response.status_code == 201
Use post to send data and a JSON dictionary as the payload.
Fill all three blanks to write a test that sends data, checks JSON response, and asserts a key.
response = client.[1]('/api/data', json=[2]) data = response.[3]() assert 'result' in data
Use post to send data, a JSON dictionary as payload, and get_json() to parse the response JSON.