Dependency Override

noun

say it: “dih-PEN-den-see OH-ver-ryd” /dɪˈpɛndənsi ˈoʊvərˌraɪd/

In FastAPI tests, replacing one of the app's dependencies with another, such as a test database or a fixed user, through app.dependency_overrides.

What is Dependency Override?

A dependency override swaps a real dependency for a fake one in tests, like a test database or a fixed user.

app.dependency_overrides[current_user] = lambda: User(id=1, name='Test User')

In a sentence

  • “The test signs in as Maya with a dependency override for current_user.”
  • “A dependency override pointed get_db at a fresh test database.”

Level: Freelancer · More FastAPI terms at this level

Updated