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'的更多相关文章

  1. 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 ...

  2. 重写用户模型时报错AttributeError: type object ‘自定义类’ has no attribute ‘USERNAME_FIELD’

    view中导入:from django.contrib.auth.models import AbstractBaseUser settings.py中设置了:AUTH_USER_MODEL='app ...

  3. AttributeError type object 'deprecated' has no attribute 'ROCKY'

    AttributeError type object 'deprecated' has no attribute 'ROCKY' 在使用kolla安装docker的时候遇到了AttributeErro ...

  4. AttributeError: type object 'testClass' has no attribute 'testMothod'

    点击"Unittest for test_post_API.testClass"按钮,点击”Edit configuration...“,弹出对话框Run/Debug config ...

  5. facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'

    报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...

  6. zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’

    在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...

  7. Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'

    报错场景 执行   celery worker -A tasks -l INFO  打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...

  8. Rasa init报错:AttributeError: type object 'Callable' has no attribute '_abc_registry'

    错误:Rasa init --no-prompt 报错 原因:Python升级到3.7后会遇到该问题 解决:pip uninstall typing

  9. 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对象 ...

随机推荐

  1. JavaScript学习之自动轮播图片

    定时器 在实现轮播图之前需要首先了解一下JavaScript的定时器 setInterval()和clearInterval() 1.setInterval() 方法可按照指定的周期(以毫秒计)来调用 ...

  2. Dynamics CRM项目实例之九:CRM 2015的产品中的捆绑销售

    关注本人微信和易信公众号: 微软动态CRM专家罗勇,回复140或者20150112可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me!      今天的博客主要是介绍Dy ...

  3. 解决PostGIS打开shp文件输入输出模块出现"找不到文件libintl-9.dll"的问题

    找到shp2pgsql-gui.exe这个程序的目录 复制一份libintl-8.dll副本,改名为libintl-9.dll即可.

  4. 生鲜配送管理系统_升鲜宝V2.0 价格组功能 操作说明_15382353715

    价格组功能是B端供应链系统,必不可少的一个功能,其主要实现不同的客户不同的价格,B端系统有一个最大的不同就是,有些商品后台下单人员能看到的.有些商品在销售的那一瞬间,还不知道价格.所以这些商品只有后台 ...

  5. Android项目实战(五十二):控制EditText输入内容大小写转换

    今日需求,EditText内容为一串字符串,要求将用户软键盘输入的小写字母在输入的时候自动转为大写字母,反之亦然. 效果如下: 第一次做该需求,原先想法: EditText.addTextChange ...

  6. C++,std::shared_future的使用

    今天给大家分享一个类似多线程任务的方法,具体如下: std::shared_future<int> tmp = std::async(p1,p2,p3); int tmpInt = tmp ...

  7. 第六篇Scrum冲刺博客

    一.Daily Scrum Meeting照片 二.每个人的工作 成员 ItemID 已完成工作 明天计划完成的工作 遇到的困难 张鸿 o1 已完成工作,实现积分变换,碰撞检测 将其他剩余功能进行整合 ...

  8. djangorestframework+vue-cli+axios,为axios添加token作为headers踩坑记

    情况是这样的,项目用的restful规范,后端用的django+djangorestframework,前端用的vue-cli框架+webpack,前端与后端交互用的axios,然后再用户登录之后,a ...

  9. eclipse 开发web 项目,使用gradle 需要安装的插件

    1.Buildship Gradle 扩展 eclipse IDE 以支持使用 Gradle 构建软件.此解决方案由 Eclipse 基金会提供 2.EGradle Editor (主要用来编写gra ...

  10. Window10上安装Redis及其客户端

    资源下载地址 Redis安装包:https://github.com/MicrosoftArchive/redis/releases Redis客户端: 链接:https://pan.baidu.co ...