python unittest单元测试

import requests
import unittest

class logintest1(unittest.TestCase):
def setUp(self):
self.test_url = "http://www.eebbk.com/"
def testlogin(self):
r = requests.get(self.test_url)
if r.status_code == int(200):
print(str(r.status_code)+" 第一条www.eebbk.com请求成功")
else:
print(str(r.status_code)+" 第一条www.eebbk.com请求失败")
self.assertEqual(r.status_code,200)

def suite():
logintestCase = unittest.TestSuite()
logintestCase.addTest(logintest1("testlogin"))
return logintestCase
if __name__ == "__main__":
unittest.main()
 
posted @ 2019-01-03 20:56  Bambooboo  阅读(235)  评论(0编辑  收藏  举报