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
原因:运行的时候光标的位置放在 test_login 方法里面了,加了ddt后,运行时要先识别装饰的类,将光标放在某一个方法后面的话,测试用例只会执行当前的方法,ddt识别不到类,就会报错,
将光标放到外面,则运行通过,或者加main方法,再运行,也不会报错
其他可能原因,setUp 或者 tearDown 拼写错误也可能报此错误
ddt运行报错AttributeError: type object 'TestLogin' has no attribute 'test_login'的更多相关文章
- ddt运行测试方法时报错AttributeError: type object 'TestHttpRq' has no attribute 'test_http_rq_login'
import unittest import ddt #装饰器 from ddt import ddt,data,unpack #导入ddt中的各个模块 from homework.unittest_ ...
- Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'
报错场景 执行 celery worker -A tasks -l INFO 打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...
- dnspython模块报错 AttributeError: 'CNAME' object has no attribute 'address'
有时候用到这个模块的时候会报错 AttributeError: 'CNAME' object has no attribute 'address' 如下所示 [root@ansible ch01]# ...
- py+selenium 明明定位不到元素,但却不报错或是报错AttributeError: 'list' object has no attribute 'click'【已解决】
问题:定位不到元素,但却不报错或者出现报错AttributeError: 'list' object has no attribute 'click' 如图 或者 解决方法: 将”driver ...
- AttributeError type object 'deprecated' has no attribute 'ROCKY'
AttributeError type object 'deprecated' has no attribute 'ROCKY' 在使用kolla安装docker的时候遇到了AttributeErro ...
- AttributeError: type object 'testClass' has no attribute 'testMothod'
点击"Unittest for test_post_API.testClass"按钮,点击”Edit configuration...“,弹出对话框Run/Debug config ...
- 运行报错:'_TestResult' object has no attribute 'outputBuffer'
一.运行main函数,未生成测试报告,报错:'_TestResult' object has no attribute 'outputBuffer' 解决方式: 1.在HTMLTestReportCN ...
- JAVA运行报错 [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
执行 String[] rwords = (String[]) list.toArray(); 报错[Ljava.lang.Object; cannot be cast to [Ljava.lang. ...
- 运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"
最近学习pytest被此问题困扰,敲脑壳,实在是不该.百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢. 报错信息如下: 网上解决方法是这样的 ...
随机推荐
- Windows下通过Composer安装Yii2
安装好大于5.4或更高版本的PHP环境并开启openssl扩展.如果是Apache服务器,加载Apache的mod_ssl模块. 下载Composer并安装. 开始->运行[或者WIN+R]-& ...
- javascript屏蔽浏览器右键功能按钮
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- LeetCode 第 231 题 (Power of Two)
LeetCode 第 231 题 (Power of Two) Given an integer, write a function to determine if it is a power of ...
- 非阻塞IO 和阻塞IO【转】
IO模式设置网络编程常见问题总结—IO模式设置,阻塞与非阻塞的比较,recv参数对性能的影响—O_NONBLOCK(open使用).IPC_NOWAIT(msgrcv).MSG_DONTWAIT(re ...
- VisualSVN 5.1.5 破解版 手动破解教程 生成dll文件
VisualSVN 5.1.5 破解版 手动破解教程 生成VisualSVN.Core.L.dll文件 附上本人用到的命令: ildasm "D:\Program Files (x86)\V ...
- 浏览器配置工具.bat
在Web安装的ActiveX控件,默认安装在C:\WINDOWS\Downloaded Program Files目录下,但是有时候由于Internet Explorer的安全设置,会阻止Active ...
- jQuery 事件的命名空间的含义
对于jquery的on的events解释是 一个或多个空格分隔的事件类型和可选的命名空间,或仅仅是命名空间,比如"click", "keydown.myPlugin&qu ...
- Segmented 标签栏 切换效果
转载:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0512/1615.html http://www.it165.net/pr ...
- 如何利用jQuery检查浏览器是否是IE6-8
$.support.leadingWhitespace是IE特有的属性,用来检查浏览器是否是IE6-8
- 判断 null undefined NaN
1.判断undefined: var tmp = undefined; if (typeof(tmp) == "undefined"){ alert("undefined ...