Python测试框架nose之设计case(2)
来源:互联网 发布:集美大学网络中 编辑:程序博客网 时间:2024/05/20 01:47
官方链接:
test tools
1.nose 框架同unittest一样支持包,模块,类级别的setUp和tearDown
所有在test模块下的函数,凡是符合正则testMatch条件((?:^|[\\b_\\.-])[Tt]est都封装入FunctionTestCase。
test functions支持函数级别的setUp
例:
def setup_func(): "set up test fixtures"def teardown_func(): "tear down test fixtures"@with_setup(setup_func, teardown_func)def test(): "test ..."
2.nose.tools的使用
- nose.tools.ok_(expr,msg=None)
Shorthand for assert. Saves 3 whole characters!
- nose.tools.eq_(a,b, msg=None)
Shorthand for ‘assert a == b, “%r != %r” % (a, b)
- nose.tools.make_decorator(func)
Wraps a test decorator so as to properly replicate metadataof the decorated function, including nose’s additional stuff(namely, setup and teardown).
- nose.tools.raises(*exceptions)
Test must raise one of expected exceptions to pass.
@raises(TypeError, ValueError)def test_raises_type_error(): raise TypeError("This test passes")@raises(Exception)def test_that_fails_by_passing(): pass
- nose.tools.set_trace()
Call pdb.set_trace in the calling frame, first restoringsys.stdout to the real output stream. Note that sys.stdout is NOTreset to whatever it was before the call once pdb is done!
- nose.tools.timed(limit)
Test must finish within specified time limit to pass.
Example use:
@timed(.1)def test_that_fails(): time.sleep(.2)
- nose.tools.with_setup(setup=None,teardown=None)
Decorator to add setup and/or teardown methods to a test function:
@with_setup(setup, teardown)def test_something(): " ... "
Note that with_setup is useful only for test functions, not for testmethods or inside of TestCase subclasses.
- nose.tools.istest(func)
Decorator to mark a function or method as a test
- nose.tools.nottest(func)
Decorator to mark a function or method as not a test
- Python测试框架nose之设计case(2)
- Python测试框架--nose
- python 测试框架nose
- python 中的测试框架 nose
- python测试框架nose研究
- python自动化测试框架nose
- python下常见测试框架之三--nose
- 学习python单元测试框架nose之---02nose多进程并行测试
- python进阶之nose框架
- Python单元测试框架之Nose
- 学习python单元测试框架nose之---01nose框架初探
- Python测试框架nose基础(1)
- python nose测试框架全面介绍二
- python nose测试框架全面介绍三
- python nose测试框架全面介绍四
- 测试框架--nose
- python单元测试框架nose的扩展nose-ittr支持传参测试
- python+selenium+nose web简单自动化测试框架
- 15款Cocos2d-x游戏源码汇总
- 读写配置文件
- Vs2012在Linux开发中的应用(9): 编译应用程序
- 杨辉三角C#编程原理
- 使用final关键字修饰一个变量的三种情况
- Python测试框架nose之设计case(2)
- Servlet跳转到jsp中无法显示css
- LPC1549如何 利用Jlink工具的J-Scope来实时观察变量,不影响CPU运行
- 基于MATLAB的滤波算法
- Golang的演化历程
- 浅析VO、DTO、DO、PO的概念、区别和用处
- 人品计算器
- iOS8 屏幕适配Size Classes
- 精选:局部变量、全局变量、堆、堆栈、静态和全局