pytest源码走读-功能模块的简介1-announce 迭代版本功能说明

背景

pytest 1.0.0.6b版本之前总共还有三个版本,版本号从大到小,分别是release-1.0.0、release-0.9.2、release-0.9.0。这三个版本是比较早期的版本,放到本地运行,是会报语法错误的。

从1.0.06b版本中的文档帮助文件doc/announce中,简单记录了各个版本提供的功能

release-0.9.2版本

py lib 0.9.2: bugfix release
=============================

Welcome to the 0.9.2 py lib and py.test release - 
mainly fixing Windows issues, providing better
packaging and integration with setuptools.

Here is a quick summary of what the py lib provides: 

* py.test: cross-project testing tool with many advanced features
* py.execnet: ad-hoc code distribution to SSH, Socket and local sub processes
* py.magic.greenlet: micro-threads on standard CPython ("stackless-light")
* py.path: path abstractions over local and subversion files 
* rich documentation of py's exported API 
* tested against Linux, Win32, OSX, works on python 2.3-2.6

See here for more information:

Pypi pages: http://pypi.python.org/pypi/py/

Download/Install:   http://codespeak.net/py/0.9.2/download.html

Documentation/API:  http://codespeak.net/py/0.9.2/index.html

best and have fun,

holger krekel 

  release-1.0.0版本

py.test / py lib 1.0.0: distributed testing and dynamic code deployment 
============================================================================

Welcome to the 1.0 release bringing new flexibility and 
power to testing with Python!  Main news: 

* new py.test plugin architecture, some examples: 

  pytest_xfail.py: mark tests as "expected to fail" 
  pytest_pocoo.py: automatically send tracebacks to pocoo paste service 
  pytest_monkeypatch.py: safely patch parts of your environment in a test function
  pytest_figleaf.py: generate html coverage reports 
  pytest_resultlog.py: generate buildbot-friendly output 

  and much more! 

* funcargs - the new flexible mechanism for managing all your test setup/fixture needs! 

* flexibly distribute tests to multiple computers from the command line

See the py.test documentation for more info: 

    http://pytest.org

The py lib contains the py.test tool and offers its well-tested code 
independently from the testing tool, mainly:

* py.execnet: ad-hoc code distribution to SSH, Socket and local sub processes
* py.code: support for dynamically running and debugging python code 
* py.path: path abstractions over local and subversion files 

The whole package works well with Linux, OSX and Win32, on 
Python 2.3, 2.4, 2.5 and 2.6.  (Expect Python3 compatibility soon!) 

Download/Install:   http://codespeak.net/py/dist/download.html 

best, 
holger 

总结起来

0.9.2版本的pytest的功能有,

py.test 具有许多高级功能的跨项目测试工具和库。

py.execnet (猜测)支持多进程多CPU多主机运行程序的工具。比如测试case过多的时候,使用这个包工具 可以更快的运行完测试case

py.magic.greenlet  是一种“微-进程” 也就是协程工具。使用时,在生成greenlet对象时,将需要执行的测试方法或者其他方法传入greenlet中。通过生成多个greenlet对象,然后显式切换协程,实现多协程之间交叉运行多方法的目的。需要注意的时,一旦当前协程在执行时,其他协程处于被挂起状态,同时,协程中的方法可以在未执行完的情况下,切其他协程,执行其他函数,具体可见https://www.jianshu.com/p/1bb68eeec54d

py.path 

使用的是python 2.3-2.6版本的运行环境,支持在Linux, Win32, OSX, works 上运行

到了下一个版本(1.0.0版本)之后,新增了以下功能

(1)在py.test.plugin 包下新增

  pytest_xfail.py : 用于对期望失败case做标记

pytest_pocoo.py: 用于将测试失败信息发送到paste.pocoo.org(todo:不是很懂这个错误信息是什么,发送的对象是什么)

pytest_monkeypatch.py: py.test插件,是一个猴子补丁,在测试执行的过程中可以动态的修改一些变量,比如pytest_monkeypatch.py提供了三种动态修改功能,包括

monkeypatch.setattr(obj, name, value) #修改对象
monkeypatch.setitem(obj, name, value) #修改字典
monkeypatch.setenv(name, value) #修改环境变量

当测试执行完成后,这些修改将被撤销

pytest_figleaf.py: 生成覆盖率报告的工具

pytest_resultlog.py: resultlog插件,用于以机器可读的方式记录测试结果。对于buildbot集成代码很有用。

【buildbot 是一个开源的基于Python的持续集成系统,即自动化软件构建,测试,发布流程的框架。】

(2)新增py.code 包,用于做源码检查,可动态运行和debug python 源码 

(3)同时,未来将尽快兼容python3的运行环境。

posted @ 2021-05-18 20:13  XiaoLee-C  阅读(147)  评论(0编辑  收藏  举报