mirror of https://github.com/xtekky/gpt4free.git
Fix unit test with missing requirements
This commit is contained in:
parent
6ef282de3a
commit
2a3880ac2f
|
@ -3,6 +3,7 @@ import asyncio
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
from .mocks import ProviderMock
|
from .mocks import ProviderMock
|
||||||
import g4f
|
import g4f
|
||||||
|
from g4f.errors import MissingRequirementsError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from g4f.gui.server.backend import Backend_Api, get_error_message
|
from g4f.gui.server.backend import Backend_Api, get_error_message
|
||||||
|
@ -34,9 +35,11 @@ class TestBackendApi(unittest.TestCase):
|
||||||
self.assertTrue(len(response) > 0)
|
self.assertTrue(len(response) > 0)
|
||||||
|
|
||||||
def test_search(self):
|
def test_search(self):
|
||||||
# Task was destroyed but it is pending!
|
|
||||||
from g4f.gui.server.internet import search
|
from g4f.gui.server.internet import search
|
||||||
result = asyncio.run(search("Hello"))
|
try:
|
||||||
|
result = asyncio.run(search("Hello"))
|
||||||
|
except MissingRequirementsError:
|
||||||
|
self.skipTest("search is not installed")
|
||||||
self.assertEqual(5, len(result))
|
self.assertEqual(5, len(result))
|
||||||
|
|
||||||
class TestUtilityFunctions(unittest.TestCase):
|
class TestUtilityFunctions(unittest.TestCase):
|
||||||
|
|
|
@ -10,6 +10,7 @@ try:
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
from selenium.common.exceptions import NoSuchElementException
|
from selenium.common.exceptions import NoSuchElementException
|
||||||
|
from undetected_chromedriver import Chrome, ChromeOptions
|
||||||
has_requirements = True
|
has_requirements = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from typing import Type as WebDriver, Callable as user_config_dir
|
from typing import Type as WebDriver, Callable as user_config_dir
|
||||||
|
@ -44,7 +45,6 @@ try:
|
||||||
super().__init__(*args, options=options, **kwargs)
|
super().__init__(*args, options=options, **kwargs)
|
||||||
has_seleniumwire = True
|
has_seleniumwire = True
|
||||||
except:
|
except:
|
||||||
from undetected_chromedriver import Chrome, ChromeOptions
|
|
||||||
has_seleniumwire = False
|
has_seleniumwire = False
|
||||||
|
|
||||||
def get_browser(
|
def get_browser(
|
||||||
|
|
Loading…
Reference in New Issue