ddt运行报错AttributeError: type object 'TestLogin' has no attribute 'test_login'
源代码:
#!usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2018/12/17 下午2:07 # @File: do_excel.py # @Software: PyCharm import unittest from api_auto.common.do_excel import DoExcel from api_auto.common.do_excel import project_path from api_auto.common.request import Request import json from ddt import ddt, data do_excel = DoExcel(project_path.CASE_FILE) cases = do_excel.get_cases("login") # 测试登录 @ddt class TestLogin(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @data(*cases) def test_login(self, case): data_dict = json.loads(case.data) response = Request(method=case.method, url=case.url, data=data_dict) print("statue_code:", response.get_statue_code()) try: self.assertEqual(case.expected, response.get_text()) except AssertionError as e: print("断言错误") raise e