03Pytest预期异常

作者: 云樱梦海 | 来源:发表于2019-07-18 23:03 被阅读0次

    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)
    

    相关文章

      网友评论

        本文标题:03Pytest预期异常

        本文链接:https://www.haomeiwen.com/subject/socdlctx.html