test_login03.py
import requests
import pytest
def test_login():
url = "http://192.168.3.4:8888/api/login"
payload = '{"username":"admin","password":"123456","recaptcha":""}'
headers = '{"Content-Type": "application/json"}'
# 预期异常AttributeError,找不到对应的对象的属性,headers是 'str'没有'items'属性
with pytest.raises(AttributeError):
requests.post(url, data=payload, headers=headers)
网友评论