Kaynağa Gözat

登录接口屏蔽

“蒋伟” 7 ay önce
ebeveyn
işleme
223ba002c0
2 değiştirilmiş dosya ile 21 ekleme ve 1 silme
  1. 21 1
      conftest.py
  2. 0 0
      test_case/test_001_登录接口.yaml

+ 21 - 1
conftest.py

@@ -1,8 +1,28 @@
+import json
+import os
+from pathlib import Path
+
 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)
 def clear_yam():
     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})

+ 0 - 0
test_case/qccq/test_001_登录接口.yaml → test_case/test_001_登录接口.yaml