Module 09 Knowledge Check
5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.
1. TestClient exercises…
- A. only the handler
- B. routing, validation, dependencies, response models and errors
- C. the network stack
- D. the database
2. A fixture that does not reset shared state produces…
- A. faster tests
- B. tests that fail depending on order
- C. better isolation
- D. no effect
3. After overriding a dependency in a test you must…
- A. restart the app
- B. clear the override
- C. reload the module
- D. nothing
4. Which assertion is worth keeping?
- A. the response equals an exact dictionary
- B. the response contains no unexpected fields
- C. the confidence equals 0.9
- D. the body length is 84
5. The offline part of the suite should…
- A. be optional
- B. run in seconds with no key
- C. run nightly
- D. require a database
---
Answer Key and Explanations
Check these only after attempting every question.
1. B - routing, validation, dependencies, response models and errors
In-process, with no server and no port to bind.
2. B - tests that fail depending on order
And the failing test is rarely the one at fault.
3. B - clear the override
Overrides are global to the app object and silently affect later tests.
4. B - the response contains no unexpected fields
It catches an internal field leaking, which is what the response model exists to prevent.
5. B - run in seconds with no key
It is where model validation, endpoint contracts and service logic all live.
Practical Check
Apply this module to your own work: complete the module activity for *Testing FastAPI Endpoints with Fixtures*, then write one sentence naming what your result shows and one naming what it does not.
Strong Answer Pattern
A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.
