Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.
Start 7-day trial →
⚡
← Courses
›
FastAPI Production
›
Module 1 · FastAPI Basics
›
Testing with pytest + httpx
quiz
9 / 105
🇺🇸
EN
▼
↗
Share
⋯
More
+100 XP
📋
Task
📖
Theory
🤖
AI Help
Task
In the test `app.dependency_overrides[current_user] = lambda: FakeUser()` — what is this pattern called and why is it powerful?
🎯 Quiz
Question
In the test `app.dependency_overrides[current_user] = lambda: FakeUser()` — what is this pattern called and why is it powerful?
A
Monkey-patching — replace the real symbol at import time so the route sees a stub. Brittle and order-dependent.
B
Dependency injection override — swap any dep with a test double without modifying the route. Cleaner than mocks.
C
Fixture chaining — pass a pytest fixture into another fixture to build up nested test setup graphs.
D
Recursive mocking — auto-mock every attribute access so deeply nested call trees never raise an AttributeError.
Submit answer
💬 Discussion
Be the first to ask a question or share a tip.
Sign in
to join the discussion. Reading is free.
Loading discussion…