From f112034cf29bd376b8db1e38ed7a574bc9351d4b Mon Sep 17 00:00:00 2001 From: Stefano Fiorucci Date: Fri, 15 Mar 2024 08:32:28 +0100 Subject: [PATCH] unpin OpenAI and fix problem with mock (#7364) --- test/components/generators/conftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/components/generators/conftest.py b/test/components/generators/conftest.py index 54a1ac5d48..5e1ad455f6 100644 --- a/test/components/generators/conftest.py +++ b/test/components/generators/conftest.py @@ -1,11 +1,11 @@ from datetime import datetime from typing import Iterator -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch import pytest from openai import Stream from openai.types.chat import ChatCompletionChunk -from openai.types.chat.chat_completion_chunk import ChoiceDelta, Choice +from openai.types.chat.chat_completion_chunk import Choice, ChoiceDelta @pytest.fixture @@ -33,8 +33,9 @@ def mock_chat_completion_chunk(): """ class MockStream(Stream[ChatCompletionChunk]): - def __init__(self, mock_chunk: ChatCompletionChunk, *args, **kwargs): - super().__init__(*args, **kwargs) + def __init__(self, mock_chunk: ChatCompletionChunk, client=None, *args, **kwargs): + client = client or MagicMock() + super().__init__(client=client, *args, **kwargs) self.mock_chunk = mock_chunk def __stream__(self) -> Iterator[ChatCompletionChunk]: