Complete the code to import the Flask testing client.
from flask import Flask from flask.testing import [1]
The Flask testing client is imported as FlaskClient from flask.testing.
Complete the code to create a test client from the Flask app.
app = Flask(__name__)
client = app.[1]()The method to create a test client in Flask is test_client().
Fix the error in the test login POST request code.
response = client.post('/login', data=[1], follow_redirects=True)
The data argument expects a dictionary with form keys and values.
Fill both blanks to check if the login response contains the welcome message.
assert [1] in response.data.decode('utf-8') and response.status_code == [2]
The response should contain the welcome message string and have status code 200 for success.
Fill all three blanks to test logout and verify redirection status code.
logout_response = client.get('/logout', follow_redirects=[1]) assert logout_response.status_code == [2] assert '[3]' in logout_response.data.decode('utf-8')
Follow redirects should be True to follow the logout redirect. The status code 302 means redirect. The login page text confirms logout success.
