forked from ScottLogic/InferLLM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eebd1e6
commit d5030bd
Showing
3 changed files
with
20 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,9 @@ | ||
# conftest.py | ||
import pytest | ||
import logging | ||
import os | ||
from unittest.mock import patch | ||
|
||
from openai import AsyncOpenAI | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_configure(config): | ||
# Set an environment variable to indicate pytest is running | ||
os.environ["PYTEST_RUNNING"] = "1" | ||
os.environ["OPENAI_API_KEY"] = "fake_key" | ||
|
||
|
||
class MockOpenAI(AsyncOpenAI): | ||
pass | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
@patch("src.llm.OpenAI.client") # Ensure this matches the import path in your module | ||
def mock_async_openai(): | ||
with patch("openai.AsyncOpenAI", MockOpenAI) as mock_async_openai: | ||
yield mock_async_openai | ||
print("AsyncOpenAI patched") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters