XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Fix unit test with missing requirements

2a3880ac
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +6 -3
Modified etc/unittest/backend.py +5 -2
@@ -3,6 +3,7 @@ import asyncio
3 3 from unittest.mock import MagicMock
4 4 from .mocks import ProviderMock
5 5 import g4f
6 from g4f.errors import MissingRequirementsError
6 7
7 8 try:
8 9 from g4f.gui.server.backend import Backend_Api, get_error_message
@@ -34,9 +35,11 @@ class TestBackendApi(unittest.TestCase):
34 35 self.assertTrue(len(response) > 0)
35 36
36 37 def test_search(self):
37 # Task was destroyed but it is pending!
38 38 from g4f.gui.server.internet import search
39 result = asyncio.run(search("Hello"))
39 try:
40 result = asyncio.run(search("Hello"))
41 except MissingRequirementsError:
42 self.skipTest("search is not installed")
40 43 self.assertEqual(5, len(result))
41 44
42 45 class TestUtilityFunctions(unittest.TestCase):
Modified g4f/webdriver.py +1 -1
@@ -10,6 +10,7 @@ try:
10 10 from selenium.webdriver.support import expected_conditions as EC
11 11 from selenium.webdriver.common.keys import Keys
12 12 from selenium.common.exceptions import NoSuchElementException
13 from undetected_chromedriver import Chrome, ChromeOptions
13 14 has_requirements = True
14 15 except ImportError:
15 16 from typing import Type as WebDriver, Callable as user_config_dir
@@ -44,7 +45,6 @@ try:
44 45 super().__init__(*args, options=options, **kwargs)
45 46 has_seleniumwire = True
46 47 except:
47 from undetected_chromedriver import Chrome, ChromeOptions
48 48 has_seleniumwire = False
49 49
50 50 def get_browser(