fix(tests): mock prisma.Prisma in backoff retry tests to avoid 'prisma generate'
PrismaClient.__init__ does `from prisma import Prisma` inline, which raises RuntimeError when the Prisma client hasn't been generated. This caused two tests to fail in CI with: Exception: Unable to find Prisma binaries. Please run 'prisma generate' first. Add an autouse fixture that replaces sys.modules['prisma'] with a MagicMock for the duration of each test, allowing PrismaClient to be instantiated and client.db to be overridden with the existing mock objects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
00530cb65c
commit
defc76b32a
@ -22,6 +22,20 @@ import httpx
|
||||
import backoff
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_prisma_binary():
|
||||
"""Mock prisma.Prisma to avoid requiring 'prisma generate' in CI.
|
||||
|
||||
PrismaClient.__init__ does `from prisma import Prisma` inline, which raises
|
||||
RuntimeError when the Prisma client hasn't been generated yet. Replacing
|
||||
sys.modules['prisma'] with a MagicMock lets the import succeed so tests can
|
||||
instantiate a real PrismaClient and override client.db with their own mocks.
|
||||
"""
|
||||
mock_module = MagicMock()
|
||||
with patch.dict(sys.modules, {"prisma": mock_module}):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_prisma_client():
|
||||
"""Create a mock PrismaClient with necessary attributes"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user