NANDHOO
.
Learning Paths
Dashboard
Sign In
Home
Dashboard
FastAPI Framework Engineering
Dependency Injection Engineering
Quiz
Chapter Quiz: Dependency Injection Engineering
Mastery Assessment: Dependency Injection
Complete this assessment with 100% score to master this chapter.
01
Why is `yield` used in database dependencies?
To make the query faster.
To manage the resource lifecycle, ensuring the database connection is closed after the request is finished.
To return multiple databases at once.
It is a requirement of Python 3.8.
02
How does FastAPI optimize multiple dependencies that require the same sub-dependency?
It runs them all in parallel.
It caches the result of the sub-dependency and reuses it for the remainder of the request scope.
It throws an error for circular dependencies.
It re-executes the sub-dependency for every caller.
03
What tool is used to swap dependencies during automated testing?
Mock.patch
app.dependency_overrides
pytest.fixture
FastAPI.replace
Submit Answers
Back to Lesson
Next Chapter