import sys
from excel import DoExecl
import paramunittest
import unittest
from BeautifulReport import BeautifulReport as report
from datetime import datetime
from unittest import TestLoader, TestSuite, TextTestRunner
i = DoExecl().readExcel()
@paramunittest.parametrized(
*i
)
class TestTest1(unittest.TestCase):
def setParameters(self, url, method, header, body, expected):
self.url = url,
self.method = method,
self.header = header,
self.body = body,
self.expected = expected
def test_go(self):
self.assertEqual(self.expected['apiStatus'], 0)
if __name__ == '__main__':
# print(type(TestTest1))
# unittest.main(verbosity=2)
now = datetime.now().strftime('%Y年%m月%d日 %H点%M分%S秒')
suit = unittest.TestSuite()
#suit.addTest(unittest.makeSuite(TestTest1))
suit.addTests(unittest.TestLoader().loadTestsFromTestCase(TestTest1))
run_report = report(suit)
run_report.report(
filename=f'{now}的测试报告',
report_dir='report',
description='用例名称',
)
Traceback (most recent call last):
File "D:/weiyang/apitest/参数化.py", line 56, in <module>
suit.addTests(unittest.TestLoader().loadTestsFromTestCase(TestDemo))
File "C:\Users\60587\AppData\Local\Programs\Python\Python38-32\lib\unittest\loader.py", line 86, in loadTestsFromTestCase
if issubclass(testCaseClass, suite.TestSuite):
TypeError: issubclass() arg 1 must be a class
<class 'NoneType'>
Process finished with exit code 1
paramunittest参数化执行用例,把测试类加到测试套件中时提示输入参数必须是一个类,不加入测试套件直接unittest.main(verbosity=2)执行的话可以执行,把paramunittest相关的部分注释掉了type(测试类)显示的就是一个class type,加上就变成了NoneType,有没有大佬解答一下,小白感激