1. 在ini文件中写入路径数据
[base_url]
jiami_url = http://192.168.0.1:5050
2. 封装路径读取方法-新建封装方法base_url.py
def read_ini():
ini = IniConfig("./pytest.ini")
if 'base_url' not in ini:
return {}
else:
return dict(ini['base_url'].items())
3. 加载读取路径
def env(self,data):
return read_ini()[data]
4. 用例中写入读取
request:
method: post
url: ${env(jiami_url)}/base64login
data:
username: ${base64_encode(admin)}
password: ${base64_encode(123)}