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"}'
# 預(yù)期異常AttributeError,找不到對應(yīng)的對象的屬性,headers是 'str'沒有'items'屬性
with pytest.raises(AttributeError):
requests.post(url, data=payload, headers=headers)