mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-14 07:48:16 +08:00

Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: chenhe <guchenhe@gmail.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
21 lines
563 B
Python
21 lines
563 B
Python
from tests.integration_tests.model_runtime.__mock.huggingface_chat import MockHuggingfaceChatClass
|
|
|
|
from huggingface_hub import InferenceClient
|
|
|
|
from _pytest.monkeypatch import MonkeyPatch
|
|
from typing import List, Dict, Any
|
|
|
|
import pytest
|
|
import os
|
|
|
|
MOCK = os.getenv('MOCK_SWITCH', 'false').lower() == 'true'
|
|
|
|
@pytest.fixture
|
|
def setup_huggingface_mock(request, monkeypatch: MonkeyPatch):
|
|
if MOCK:
|
|
monkeypatch.setattr(InferenceClient, "text_generation", MockHuggingfaceChatClass.text_generation)
|
|
|
|
yield
|
|
|
|
if MOCK:
|
|
monkeypatch.undo() |