diff --git a/conftest.py b/conftest.py index 54f70e7d8dc233ae14c249428feb4dfe46a13b0c..2d348a7c66de66fa1c72dde911ad998cf279b35f 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()