mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-20 00:11:50 +00:00
Merge pull request #21421 from BerriAI/fix/mock-prisma-in-backoff-tests
fix(tests): mock prisma.Prisma in backoff retry tests to avoid 'prisma generate'
This commit is contained in:
commit
153af8b901
1 changed files with 14 additions and 0 deletions
|
|
@ -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…
Add table
Reference in a new issue