Commit 4fc7c882 authored by 王超's avatar 王超

conftest.py文件

parent 9a2ccf70
......@@ -151,6 +151,30 @@ def project_init():
except Exception as e:
error_log(f"获取工程信息失败:{e}")
"""导入内部变量,并启动变量服务"""
url = Config.url + r"/api/v1/variable/import"
x_project = DubugTalk().read_extract_file("x_project")
header = {'X-Project': f"{x_project}"}
file_path = Config.root_dir + r"\ProjectData\内部变量.xlsx"
try:
with open(file_path, 'rb') as file:
files = {'file': ('filename', file, 'text/plain')}
re = requests.post(url=url, headers=header, files=files)
print()
if re.status_code != 200:
print("变量导入失败:", re.status_code)
except Exception as e:
error_log(f"变量导入失败:{e}")
# 启动变量服务
try:
url = Config.url + r"/api/v1/project/service/var/start"
re = requests.post(url=url, headers=header)
if re.status_code != 200:
print("启动变量服务失败:", re.status_code)
except Exception as e:
error_log(f"启动变量服务失败:{e}")
@pytest.fixture(scope="session", autouse=True)
def upload_image():
"""
......@@ -211,34 +235,7 @@ def create_page():
error_log(f"画面删除失败,状态码为{re.status_code}")
except Exception as e:
error_log(f"页面删除失败:{e}")
@pytest.fixture(scope="function", autouse=True)
def import_var():
"""
导入内部变量,并启动变量服务
:return:
"""
url = Config.url + r"/api/v1/variable/import"
x_project = DubugTalk().read_extract_file("x_project")
header = {'X-Project': f"{x_project}"}
file_path = Config.root_dir + r"\ProjectData\内部变量.xlsx"
try:
with open(file_path, 'rb') as file:
files = {'file': ('filename', file, 'text/plain')}
re = requests.post(url=url, headers=header, files=files)
print()
if re.status_code!=200:
print("变量导入失败:",re.status_code)
except Exception as e:
error_log(f"变量导入失败:{e}")
# 启动变量服务
try:
url = Config.url + r"/api/v1/project/service/var/start"
re = requests.post(url=url, headers=header)
if re.status_code!=200:
print("启动变量服务失败:",re.status_code)
except Exception as e:
error_log(f"启动变量服务失败:{e}")
@pytest.fixture(scope="function", autouse=False)
def write_var():
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment