123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import json
- import os
- from pathlib import Path
- import pytest
- import requests
- from common.yaml_util import clear_yaml, read_testcase, read_config_yaml, write_yaml, clear_out_yaml
- path = Path(__file__).parent.glob("**/test_001_登录接口.yaml")
- for yaml_path1 in path:
- yaml_path = yaml_path1
- # path = Path(__file__).parent.glob("**/test_001_登录接口验证码.yaml")
- # for yaml_path1 in path:
- # yzm_path = yaml_path1
- @pytest.fixture(scope="session", autouse=True)
- def clear_yam():
- clear_yaml()
- clear_out_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})
- # def yzm_login(yzm_path):
- # global i
- # data = read_testcase(yzm_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'])
- # print(111111111111111111,res)
|