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_http_request_20190321.Method_http_request import * @ddt #装饰测试类
class TestHttpRq(unittest.TestCase): #测试类-get请求 @data({"mobilephone":"","pwd":""},
{"mobilephone":"","pwd":""},
{"mobilephone": "", "pwd": ""},
{"mobilephone":"","pwd":""}) #装饰方法,遍历data中的元素
def test_http_rq_login(self,login_data):#测试用例必须以test开头,不然报错
exp = ["用户名或密码错误","登录成功","手机号不能为空","密码不能为空"]
res = HttpRequest("get",login_data).http_request().json()['msg']
self.assertIn(res,exp)#断言,判断实际值与预期值是否一致
D:\Python34\python.exe "D:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pycharm\_jb_unittest_runner.py" --target unittest_http_rq.TestHttpRq.test_http_rq_login
Testing started at 13:10 ...
Launching unittests with arguments python -m unittest unittest_http_rq.TestHttpRq.test_http_rq_login in D:\python15期\homework\ddt_20190323 Traceback (most recent call last):
File "D:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pycharm\_jb_unittest_runner.py", line 35, in <module>
main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
File "D:\Python34\lib\unittest\main.py", line 92, in __init__
self.parseArgs(argv)
File "D:\Python34\lib\unittest\main.py", line 139, in parseArgs
self.createTests()
File "D:\Python34\lib\unittest\main.py", line 146, in createTests
self.module)
File "D:\Python34\lib\unittest\loader.py", line 157, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "D:\Python34\lib\unittest\loader.py", line 157, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name in names]
File "D:\Python34\lib\unittest\loader.py", line 125, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: type object 'TestHttpRq' has no attribute 'test_http_rq_login' Process finished with exit code 1
Empty test suite.
运行程序时将鼠标定位在类或者程序外运行解决,ddt只能运行整体,不能运行局部即单个测试方法
ddt运行测试方法时报错AttributeError: type object 'TestHttpRq' has no attribute 'test_http_rq_login'的更多相关文章
- 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 # @Sof ...
- 重写用户模型时报错AttributeError: type object ‘自定义类’ has no attribute ‘USERNAME_FIELD’
view中导入:from django.contrib.auth.models import AbstractBaseUser settings.py中设置了:AUTH_USER_MODEL='app ...
- 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 ...
- facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'
报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...
- zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’
在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...
- Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'
报错场景 执行 celery worker -A tasks -l INFO 打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...
- Rasa init报错:AttributeError: type object 'Callable' has no attribute '_abc_registry'
错误:Rasa init --no-prompt 报错 原因:Python升级到3.7后会遇到该问题 解决:pip uninstall typing
- PHP json_decode object时报错Cannot use object of type stdClass as array
PHP json_decode object时报错Cannot use object of type stdClass as array php再调用json_decode从字符串对象生成json对象 ...
随机推荐
- springMVC实现增删改查
首先需要准备好一张数据库表我这里用emp这张表:具体代码: /* SQLyog 企业版 - MySQL GUI v8.14 MySQL - 5.1.73-community ************* ...
- Web后端 JAVA实现验证码生成与验证功能
首先,写一个验证码生成帮助类,用来绘制随机字母: <span style="font-size:14px;">import java.awt.Color; impor ...
- 一起学Android之GridView
本文以一个简单的小例子,简述Android开发中GridView的常见应用,仅供学习分享使用. 概述 GiridView是一个表格显示资源的控件,可以在两个可滚动的方向上显示.列表项的资源会通过Lis ...
- [Python] wxPython 高防Windows10记事本 (end...)
1.开始 接触Python 也有一段时间了,o.o ,断断续续加起来没几天. 一般新学习一门新语言,除了必先输出一个 Hello World 外,都会以模拟 Windows 记事本来写一个结合自己想法 ...
- Java Web相关问题
关于这两天主要问题的解答: (1) 驱动程序无法使用安全套接字层(SSL)加密与 SQL Server 建立安全连接.错误: java.lang.RuntimeException: Could no ...
- selenium-测试框架搭建(十三)
思路 分离业务代码和测试数据,提高代码可维护性,实现自动化,减少重复劳动. 一个测试框架大概由配置文件,测试数据,测试用例,相关文件(发送邮件等),测试日志,断言和测试报告等模块组成. 结构 以页面为 ...
- WebApi接收post方式传入的json数据
[RoutePrefix("Api")] public class UploadController:BaseApiController { [HttpPost] [Route(& ...
- Linux学习历程——Centos 7 find 命令
一.命令介绍 find 命令用于按照指定条件来查找文件. 一些比较常用参数如下表 参数 作用 -name 匹配名称 -perm 匹配权限mode为完全匹配( –mode包含即可) -user 匹配所有 ...
- name 'reload' is not defined解决方法
今天在学习scrapy的时候,在网上找了一段代码,运行出了一点问题. 命令行报错: name 'reload' is not defined 原因是,python版本的问题 原代码如下: import ...
- Delphi 拦截输入法输入结果
{ 拦截输入法输入的字符串.向编辑框中输入中文查看效果. Delphi XE7 } unit Unit1; interface uses Winapi.Windows, Winapi.Messages ...