import unittest,HTMLTestRunner
from nose_parameterized import parameterized def login(username,passwd):
if username=='niuhanyang' and passwd=='':
return ''
return False
def choujiang(sign):
if sign == '':
return True
return False class My(unittest.TestCase):
def alogin(self, username, passwd, hope):
sign = login(username, passwd)
return sign
@parameterized.expand(
[
['niuhanyang','',''],
['niuhanyang','',False],
['','', False],
['niuhanyang','',False]
]
)
def test_choujiang(self,username,passwd,hope):#只有test开头的用例才会被执行
sign=self.alogin(username,passwd,hope) #获取前一条用例的执行结果,赋值给sign
cj_res=choujiang(sign)
self.assertEqual(cj_res,True)
if __name__=='__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(My))
fw = open('获取结果.html', 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fw, title='获取前一条用例执行结果')
runner.run(suite)

执行结果

Python-获取前一条用例的执行结果-LMLPHP

05-23 01:07