From 2a3880ac2f51f2a02ba64fe6bb2547e221580e93 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Tue, 12 Mar 2024 02:15:22 +0100 Subject: Fix unit test with missing requirements --- etc/unittest/backend.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'etc/unittest/backend.py') diff --git a/etc/unittest/backend.py b/etc/unittest/backend.py index c4ab219e..ee6174d5 100644 --- a/etc/unittest/backend.py +++ b/etc/unittest/backend.py @@ -3,6 +3,7 @@ import asyncio from unittest.mock import MagicMock from .mocks import ProviderMock import g4f +from g4f.errors import MissingRequirementsError try: from g4f.gui.server.backend import Backend_Api, get_error_message @@ -34,9 +35,11 @@ class TestBackendApi(unittest.TestCase): self.assertTrue(len(response) > 0) def test_search(self): - # Task was destroyed but it is pending! 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)) class TestUtilityFunctions(unittest.TestCase): -- cgit v1.2.3