From cf430e353f4be7284a85feaced325194f122d17e Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Tue, 12 Mar 2024 16:27:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96clientId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conftest.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index 54f70e7..2d348a7 100644 --- a/conftest.py +++ b/conftest.py @@ -7,9 +7,7 @@ from Utils import config_handler from Utils import global_variate from Utils import websocket_handler - session = requests.session() - def willdesk_login(): ''' 执行用例前获取登录态的接口,全局只执行一次,通过env参数控制是否测试环境 @@ -93,7 +91,6 @@ def customer_login(): setattr(global_variate.Global,'customerName',login_res['data']['name']) address = 'wss://atestws.sealapps.com/ws' if env == 'test' else 'wss://ws.willdesk.com/ws' print(f'{address}?platform=1&authorization={global_variate.Global.access_token}&t={int(time.time())}') - websocket_handler.ws_willdesk = websocket_handler.ws( url=f'{address}?platform=1&authorization={global_variate.Global.access_token}&t={int(time.time())}', attr='willdesk') # willdesk账号websocket链接 @@ -103,13 +100,19 @@ def customer_login(): async def close_ws(): await asyncio.gather(asyncio.create_task(websocket_handler.ws_willdesk.close()),asyncio.create_task(websocket_handler.ws_client.close())) + +async def get_client_id(): + await asyncio.gather(asyncio.create_task(websocket_handler.ws_willdesk.get_client_id()),asyncio.create_task(websocket_handler.ws_client.get_client_id())) + + +loop = websocket_handler.loop @pytest.fixture(scope='session',autouse=True) def call_fixture(): #自定义调用顺序 willdesk_login() customer_login() + loop.run_until_complete(get_client_id()) #初始化获取clientid yield - loop = websocket_handler.loop - loop.run_until_complete(close_ws()) + loop.run_until_complete(close_ws()) #关闭服务 loop.stop() loop.close() -- GitLab