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. js调用百度地图接口绘制任意多边形并获取每个点的经纬度等

    来自:https://blog.csdn.net/u013239236/article/details/52213977 侵删 <!DOCTYPE html> <html> & ...

  2. wordpress的excerpt()函数

    问题:在wordpres中的single页面,本身引用的<?php the_excerpt(); ?>,但是在页面上显示的却是文章的内容 原因:the_excerpt(); 在excerp ...

  3. 两种方法实现asp.net方案的前后端数据交互(aspx文件、html+ashx+ajax)

    一个HTML页面只能显示HTML代码信息,不能与数据库进行数据的交互.asp.net方案提供了网页与数据库交互的方法,这里举出两种:①aspx文件 ②ashx文件+ajax技术 一.创建数据库 这里以 ...

  4. MVC 伪静态路由、MVC路由配置,实现伪静态。

    前段时间,研究了一下mvc路由配置伪静态,在网上扒了很多最后还是行不通,所以我现在把这些心得整理出来,供大家分享: 1.mvc中默认路由配置是:http://localhost:24409/Home/ ...

  5. IOS以无线方式安装企业内部应用(开发者)

    请先阅读:http://help.apple.com/deployment/ios/#/apda0e3426d7 操作系统:osx yosemite 10.10.5 (14F1509) xcode:V ...

  6. Python-语法模板大全(常用)

    目录 1.怎么存数据 变量: 字符串: 不可变对象 列表: 元组: 字典: 三大容器的遍历方法 2.怎么用数据 数字操作符: 判断循环: 3.函数 4. Python核心编程 4.1. 列表生成器 5 ...

  7. python学习——读取染色体长度(四:获取最长染色体的编号)

    # 读取fasta # 解析每条序列的长度 chr_len = {'chr1':10,'chr2':20,'chr3':30,'chr4':40,'chr5':15} # 求和 total_len = ...

  8. Scala--控制结构和函数

    一.条件表达式 val s = if(x > 1) 1 else -1 s 可以是 val var s = 0 if(x > 1) s = 1 else s = -1 s 必须是 var ...

  9. 02-MySQL基础

    MySQL基础 1.存储引擎 1.1MyISAM MySQL5.5以及之前默认存储引擎MyISAM 如果应用是以读操作和插入操作为主,只有很少的更新和删除操作,并且对事务的完整性.并发性要求不高,那么 ...

  10. PHP为前端CSS和JS增加时间戳版本号

    一.PHP代码如下: function addVersion($url){ $version = date("Y-m-d H:i:s",filemtime($_SERVER['DO ...