l 模块化parametrizeable装置(在2.3,持续改进)
l 参数化测试函数(用例)
l 标记测试功能与属性
l Skip和xfail:处理不成功的测试用例(在2.4改进)
l 通过xdist插件分发测试到多个CPU
l 不断地重新运行失败的测试
l 灵活约定的Python测试发现
Home Page: http://pytest.org
安装
>pip install -U pytest # 通过pip安装
>py.test --version # 查看pytest版本
This is pytest version 2.7.2, imported from C:\Python27\lib\site-packages\pytest.pyc
class DictImporter(object):
def __init__(self, sources):
self.sources = sources
def find_module(self, fullname, path=None):
if fullname == "argparse" and sys.version_info >= (2,7):
# we were generated with <python2.7 (which pulls in argparse)
# but we are running now on a stdlib which has it, so use that.
return None
if fullname in self.sources:
return self
if fullname + '.__init__' in self.sources:
return self
return None
def load_module(self, fullname):
# print "load_module:", fullname
from types import ModuleType
try:
s = self.sources[fullname]
is_pkg = False
except KeyError:
s = self.sources[fullname + '.__init__']
is_pkg = True