A. Using single equals '=' instead of double '==' in assertion
B. Missing parentheses in response.json call
C. Incorrect endpoint URL format
D. No error, code is correct
Solution
Step 1: Check assertion syntax
The line assert response.status_code = 200 uses single '=' which is assignment, not comparison.
Step 2: Confirm correct assertion operator
Assertions require '==' to compare values, so it should be assert response.status_code == 200.
Final Answer:
Using single equals '=' instead of double '==' in assertion -> Option A
Quick Check:
Use '==' for comparison in assert [OK]
Hint: Use '==' in assert, not '=' [OK]
Common Mistakes:
Confusing assignment '=' with comparison '=='
Forgetting parentheses in method calls
Assuming no syntax error in assert
5. You want to test an API client method that sends a POST request with JSON data and expects a 201 status code. Which pytest test code correctly performs this check?