From 16159520feb03b96f099d1c03f3a1fcb5e24534d Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Thu, 7 Mar 2024 18:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=B3=E9=97=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E9=93=BE=E6=8E=A5=E3=80=81=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conftest.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index 1bc522b..2c5100b 100644 --- a/conftest.py +++ b/conftest.py @@ -1,3 +1,5 @@ +import asyncio +from Utils.sql_handler import test_env_conn import pytest import requests import time @@ -88,6 +90,7 @@ def customer_login(): login_res = session.post(url=login_url,json=data,headers=headers).json() setattr(global_variate.Global,'clientToken',login_res['data']['accessToken']) setattr(global_variate.Global,'customerId',login_res['data']['customerId']) + 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())}') @@ -98,9 +101,17 @@ def customer_login(): url=f'{address}?platform=1&authorization={global_variate.Global.clientToken}&t={int(time.time())}', attr='customer') # c端websocket链接 - +async def close_ws(): + await asyncio.gather(asyncio.create_task(websocket_handler.ws_willdesk.close()),asyncio.create_task(websocket_handler.ws_client.close())) @pytest.fixture(scope='session',autouse=True) def call_fixture(): #自定义调用顺序 willdesk_login() - customer_login() \ No newline at end of file + customer_login() + yield + test_env_conn.close_db() + loop = websocket_handler.loop + loop.run_until_complete(close_ws()) + loop.stop() + loop.close() + -- GitLab