python3+requests接口自动化-测试登陆

测试之前封装的login模块

 1 import unittest
 2 from case.login import test_user_login
 3 from common.logger import Log
 4 
 5 class Test(unittest.TestCase):
 6     log = Log()
 7 
 8     def test_Login(self):
 9         '''测试登陆'''
10         self.log.info("---------start---------")
11         result =test_user_login().test_Login()
12         try:
13             self.log.info("调用登陆结果:%s" %result)
14             self.log.info("获取是否登陆成功:%s"%result.text)
15             self.assertEqual(result.status_code, 200)  # 拿结果断言
16             self.log.info("---------test is pass---------")
17             self.log.info("---------end---------")
18         except:
19             self.log.info("---------test is fail---------")
20 
21 if __name__ == "__main__":
22     unittest.main()

 

posted @ 2018-10-23 13:12  jaysonzxk  阅读(675)  评论(0编辑  收藏  举报