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. es6基础知识

    1.超引用:(...) 用于取出参数对象中的所有可遍历属性,拷贝到当前对象之中 function fun(...args){ console.log(args); //[1,2,3,4,5,6] ar ...

  2. HttpClient 报错 Invalid cookie header, Invalid 'expires' attribute: Thu, 01 Jan 1970 00:00:00 GMT

    今天在给我姐夫写一个 QQ 自动加好友的程序,但是在 HttpClient 登陆 QQ 的时候报了一个错: -- ::] - Invalid cookie header: Jan :: GMT -- ...

  3. 局域网git服务器搭建(基于win7 + bonobo git server)

    公司内网有一台win7系统的服务器. 准备在上面部署git后台, 用于内网项目版本管理. 搜索了相关资料后, 在根据公司环境, 决定采用win7 + bonobo git server + git的方 ...

  4. django csrf token添加

    #views.py from django.shortcuts import render_to_response, RequestContext from django.views.decorato ...

  5. CentOS 6忘记root密码的解决办法

    1.在开机启动的时候按键盘上的“E”键 或者“ESC”键,会进入如下界面 2.选择相应的内核,再次按“E”,出现下图,选择第二项,再次按“E”键 3.经过第二步,这个画面可以编辑,在信息的最后加“空格 ...

  6. Webdriver之API详解(1)

    说明 Webdriver API详解,基于python3,unittest框架,driver版本和浏览器自行选择. 本内容需要对python3的unittest框架有一个简单的了解,这里不再赘述,不了 ...

  7. Kafka Tuning Recommendations

    Kafka Brokers per Server Recommend 1 Kafka broker per server- Kafka not only disk-intensive but can ...

  8. handsontable合并表头

    想在页面中做类似excel的操作,发现handsontable符合要求. 然后发现这个文章 http://blog.csdn.net/wynan830/article/details/9054195 ...

  9. ASP.NET Core RSA加密或解密

    前言 这两天主要是公司同事用到了RSA加密,事后也看了下,以为很简单,最终利用RSACryptoServiceProvider来实现RSA加密,然后大致了解到RSACryptoServiceProvi ...

  10. 分布式存储ceph——(2)openstack对接ceph存储后端

    ceph对接openstack环境 一.使用rbd方式提供存储如下数据: (1)image:保存glanc中的image: (2)volume存储:保存cinder的volume:保存创建虚拟机时选择 ...