Bird
0
0

What will be the output of this Flask test code?

medium📝 component behavior Q4 of 15
Flask - Testing Flask Applications
What will be the output of this Flask test code?
client = app.test_client()
response = client.get('/hello')
print(response.status_code)

Assuming the '/hello' route returns HTTP 200.
A200
B404
C500
DNone
Step-by-Step Solution
Solution:
  1. Step 1: Understand test client GET request

    The test client sends a GET request to '/hello' route.
  2. Step 2: Check expected status code from route

    The route returns HTTP 200, so response.status_code is 200.
  3. Final Answer:

    200 -> Option A
  4. Quick Check:

    Test client GET status = 200 [OK]
Quick Trick: Response status_code shows HTTP status from route [OK]
Common Mistakes:
MISTAKES
  • Expecting 404 for existing route
  • Confusing status_code with response data
  • Assuming None if no explicit return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes