python学习笔记9-单元测试unittest】的更多相关文章

官方参考文档:http://docs.python.org/2.7/library/unittest.html unittest是一个python版本的junit,junit是java中的单元测试框架,对java的单元测试,有一句话很贴切:Keep the bar green,相信使用eclipse写过java单元测试的都心领神会.unittest实现了很多junit中的概念,比如我们非常熟悉的test case, test suite等,总之,原理都是相通的,只是用不同的语言表达出来. uni…
unittest 单元测试的一个框架什么框架 一堆工具的集合. TestCase TestSuite 测试套件,多个用例在一起 TestLoader是用来加载TestCase到TestSuite中的 TestRunner是来执行测试用例的,测试的结果会保存到TestResult实例中, 包括运行了多少测试用例,成功了多少,失败了多少等信息 用例必须以test开头 import unittest import HTMLTestRunner from BeautifulReport import B…
Python中有一个自带的单元测试框架是unittest模块,用它来做单元测试,它里面封装好了一些校验返回的结果方法和一些用例执行前的初始化操作. 在说unittest之前,先说几个概念: TestCase 也就是测试用例 TestSuite 多个测试用例集合在一起,就是TestSuite TestLoader是用来加载TestCase到TestSuite中的 TestRunner是来执行测试用例的,测试的结果会保存到TestResult实例中,包括运行了多少测试用例,成功了多少,失败了多少等信…
准备先利用之前整理的python自带的unittest框架 整合excel 实现接口自动化测试功能 先看看excel表格设置: 下来是对excel获取的代码: #!/usr/bin/env python # -*- coding: utf_8 -*- import xlrd import json class Create_excel: def open_excel(self,path): workbook = xlrd.open_workbook(path) table = workbook.…
Python学习笔记(十三): 模块 包 if name == main 软件目录结构规范 作业-ATM+购物商城程序 1. 模块 1. 模块导入方法 import 语句 import module1[, module2[,... moduleN] # 当我们使用import语句的时候,Python解释器通过自己的搜索路径(存在sys.path里)进行搜索 from-import 语句 from modname import name1[, name2[, ... nameN]] # 这个声明不…
python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返回元素个数 d[key] Return the item of d with key key. Raises a KeyError if key is not in the map. If a subclass of dict defines a method _missing_() and key…
前言 前面我简单介绍了Python的Hello World.看到有人问我搞搞Python的Web,一时兴起,就来试试看. 第一篇 VS2013中Python学习笔记[环境搭建] 简单介绍Python环境的搭建过程,以及Hello World的实现. 第二篇 VS2013中Python学习笔记[基础入门] 我简单学习使用了Python的几个基础的知识点. 第一个Web页面 第一步:首先打开VS2013开发工具 ,新建项目,选择Django Project模版. 修改项目名称,可以查看到项目的文件结…
个人总结: import module,module就是文件名,导入那个python文件 import package,package就是一个文件夹,导入的文件夹下有一个__init__.py的文件, __init__.py可以有两种形式, 一种是直接import多个模块,例如 import fibo import abc 另外一种是 __all__ = ["A","B"] python学习笔记之module && package python的mo…
python学习笔记(六) 文件夹遍历 1.递归遍历 import os allfile = [] def dirList(path): filelist = os.listdir(path) for filename in filelist: filepath=os.path.join(path,filename) if(os.path.isdir(filepath)): dirList(filepath) allfile.append(filepath) return allfile pri…
接上一节  python学习笔记--Django入门四 管理站点 设置字段可选 编辑Book模块在email字段上加上blank=True,指定email字段为可选,代码如下: class Author(models.Model): first_name = models.CharField(max_length=) last_name = models.CharField(max_length=) email = models.EmailField(blank=True ) 所有字段都默认bl…