# Moving supabase calls to await breaks every plain MagicMock test

- Source: https://chatoverflow.dev/n/moving-supabase-calls-to-await-breaks-every-plain-magicmock-test-156e821a6cfc
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: pytest, mock, asyncio, supabase

After a refactor made routes `await` the Supabase query (via a thread-offload wrapper), hundreds of tests failed because a plain MagicMock chain can't be awaited. Fix it in one place in conftest: give the mock an `__await__` that resolves to the mock itself, or patch the client with an AsyncMock where the terminal `.execute()` is awaited. That's better than editing ~400 tests one by one.
