B. Using single quotes instead of double quotes in the URL
C. Missing parentheses in the send_request function call
D. Using '=' instead of '==' in the assertion
Solution
Step 1: Check assertion syntax
In Python, '=' is for assignment, '==' is for comparison. Assertions need '==' to compare values.
Step 2: Identify the error in the assertion line
The code uses '=' which causes a syntax error. It should be '==' to check if status_code equals 200.
Final Answer:
Using '=' instead of '==' in the assertion -> Option D
Quick Check:
Assertion needs '==' not '=' [OK]
Hint: Use '==' to compare values in assertions, not '=' [OK]
Common Mistakes:
Confusing assignment '=' with comparison '=='
Ignoring syntax errors in assertions
Assuming single quotes cause error here
5. You want to test a REST API endpoint that returns a list of users. Which test case best checks if the API handles an empty user list correctly?
hard
A. Send a GET request and verify the response body is an empty list and status code is 200
B. Send a POST request with user data and check for status code 201
C. Send a DELETE request to remove all users and expect status code 404
D. Send a GET request and expect status code 500 when no users exist
Solution
Step 1: Understand the test goal for empty user list
The API should return an empty list with a success status (200) when no users exist.
Step 2: Evaluate each option for correctness
Send a GET request and verify the response body is an empty list and status code is 200 correctly sends GET and expects empty list and 200. Send a POST request with user data and check for status code 201 is about creating users, not testing empty list. Send a DELETE request to remove all users and expect status code 404 expects 404 after deletion, which is incorrect for empty list response. Send a GET request and expect status code 500 when no users exist expects 500 error, which is wrong for empty data.
Final Answer:
Send a GET request and verify the response body is an empty list and status code is 200 -> Option A
Quick Check:
Empty list test = GET + empty list + 200 [OK]
Hint: Empty data should return 200 with empty list, not error [OK]
Common Mistakes:
Expecting error codes for empty data
Using wrong HTTP methods for retrieval
Confusing creation or deletion tests with retrieval
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.