|
@@ -1,8 +1,28 @@
|
|
|
|
+import json
|
|
|
|
+import os
|
|
|
|
+from pathlib import Path
|
|
|
|
+
|
|
import pytest
|
|
import pytest
|
|
|
|
+import requests
|
|
|
|
|
|
-from common.yaml_util import clear_yaml, clear_yaml_projectCode
|
|
|
|
|
|
+from common.yaml_util import clear_yaml, clear_yaml_projectCode, read_testcase, read_config_yaml, write_yaml
|
|
|
|
|
|
|
|
+path = Path(__file__).parent.glob("**/test_001_登录接口.yaml")
|
|
|
|
+for yaml_path1 in path:
|
|
|
|
+ yaml_path=yaml_path1
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def clear_yam():
|
|
def clear_yam():
|
|
clear_yaml()
|
|
clear_yaml()
|
|
|
|
+ login_system(yaml_path)
|
|
|
|
+
|
|
|
|
+def login_system(yaml_path: Path):
|
|
|
|
+ global i
|
|
|
|
+ data = read_testcase(yaml_path)
|
|
|
|
+ for i in data:
|
|
|
|
+ method = i['request'].pop("method")
|
|
|
|
+ url =read_config_yaml("base", "base_qccq_sc")+ i['request'].pop("url")
|
|
|
|
+ # 发送请求
|
|
|
|
+ res = requests.request( method, url, **i['request'])
|
|
|
|
+ token = res.json()['data']["token"]
|
|
|
|
+ write_yaml({"token":token})
|