import unittest, HTMLTestRunner
def login(username, passwd):
if username == 'sunshujiang' and passwd == '123456':
return '111'
return False
def choujiang(sign):
if sign == '111':
return True
return False
class My(unittest.TestCase):
def login(self):
sign = login('sunshujiang','123456')
self.assertEqual(sign,'111')
return sign
def test_choujiang(self):
sign = self.login() # 获取前一条用例的结果,获取登录成功的sign
cj_res = choujiang(sign)
self.assertEqual(cj_res,True)
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(My))
fw = open('login2.html', 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fw, title='登录测试结果')
runner.run(suite)