python之一测试用例
# coding=utf-8 def login_check(username=None, passwd=None): if (not username) and (not passwd): if username == 'ceshi' and passwd == '123456': return {"code": 0, "messg": "登陆成功"} else: return {"code": 1, "messg": "账号和密码不正确"} else: return {"code": 2, "messg": "账号和密码不能为空"} if __name__ == '__main__': #第一条:账号、密码正确,预期结果 excepted={"code": 0, "messg": "登陆成功"} reslut = login_check(username='ceshi', passwd='123456') print('result==', reslut) if excepted==reslut: print("测试用例通过") else: print("测试用例未通过") #第二条:账号、密码不正确,预期结果:账号密码不正确 excepted={"code": 1, "messg": "账号密码不正确"} reslut = login_check(username='ceshi', passwd='1234567') print('result==', reslut) if excepted==reslut: print("测试用例通过") else: print("测试用例未通过")