From e0966b6e51b11fd28fad145202a434620506e283 Mon Sep 17 00:00:00 2001 From: userpj Date: Wed, 13 Nov 2024 19:48:32 +0800 Subject: [PATCH] update unittest --- python/tests/test_utils.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/python/tests/test_utils.py b/python/tests/test_utils.py index 0ded0046d..3195536b9 100644 --- a/python/tests/test_utils.py +++ b/python/tests/test_utils.py @@ -17,7 +17,7 @@ from unittest.mock import MagicMock from appbuilder.utils.sse_util import SSEClient,Event from appbuilder.utils.model_util import RemoteModel,Models -from appbuilder.utils.logger_util import LoggerWithLoggerId,_setup_logging +from appbuilder.utils.logger_util import LoggerWithLoggerId,_setup_logging,logger from threading import current_thread # 创建一个logger类 @@ -40,7 +40,7 @@ def test_sse_util_SSEClient(self): # 测试是否抛出 StopIteration 异常,表示没有更多事件 with self.assertRaises(StopIteration): next(event_generator) - + # test_events mock_event_source.__iter__.return_value = iter([ b': Test event 1\n\n', @@ -50,28 +50,30 @@ def test_sse_util_SSEClient(self): b'event:Testevent5\n\n', ]) sse_client = SSEClient(event_source=mock_event_source) + for event in sse_client.events(): + pass + + logger.setLoglevel("DEBUG") for event in sse_client.events(): pass # test_close sse_client.close() - + def test_sse_util_Event(self): # test_str_ event_str=str(Event(id='id',retry=10)) assert event_str.startswith('message') - + def test_model_util_RemoteModel(self): # test_get_remote_name_by_short_name rm=RemoteModel(remote_name='test_remote') rm.get_remote_name_by_short_name(short_name="eb-turbo-appbuilder") - + def test_model_util_Models(self): # test_list models=Models() models.list(retry=-1) - - + + if __name__ == '__main__': unittest.main() - - \ No newline at end of file