codejump

Overrides & Test Isolation

Preview — 3 of 10 questions

How does a test replace a FastAPI dependency named get_user?

ASet app.dependency_overrides[get_user] = fake_user
BSet get_user = None only inside the test
CEdit the OpenAPI JSON manually
DPass dependency=fake_user to client.get

Why should a test restore app.dependency_overrides after using a fake dependency?

APytest requires every mapping to be serialized
BOverrides can otherwise leak into later tests
CThe route path changes permanently
DThe response body cannot be parsed

A route depends on an external payment provider. What should a route-focused test usually override?

AThe HTTP method with GET
BThe response status with 200
CThe provider dependency with a controlled fake
DThe entire pytest runner

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.