# coding=utf-8
import unittest
from ddt import ddt, data, unpack
import threading
from common import HTMLTestRunner_cn

@ddt
class MyTestCase(unittest.TestCase):
def setUp(self):
print("this is setup")

# 用元组存放数据,一个参数
@data(1,-3,'coco','')
def testcase01(self, value):
print(value)
self.assertEqual(1, value)

@data((1,2),(2,4))
@unpack
def testcase02(self, value1, value2):
print(value1, value2)
self.assertEqual(value1,value2-1)

def tearDown(self):
print("this is tearDown")

def test_suite(i):
cases = unittest.TestLoader().loadTestsFromTestCase(MyTestCase)
suite = unittest.TestSuite([cases])
html_file = r"D:/jdcj/report/result"+str(i)+".html"
fp = open(html_file, 'wb')
HTMLTestRunner_cn.HTMLTestRunner(stream=fp,verbosity=2,title="测试报告",description="测试案例执行结果").run(suite)

if __name__ == '__main__':
# unittest.main()
threads = []
for i in range(2):
t = threading.Thread(target=test_suite, args=(i,))
threads.append(t)
for j in threads:
j.start()