我们可以自己自定义一个插件扩展测试框架功能,写个插件类继承Plugin就可以
import logging
import os
from nose.plugins import Plugin
log = logging.getLogger('nose.plugins.helloworld')
class HelloWorld(Plugin):
name = 'helloworld'
def options(self, parser, env=os.environ):
super(HelloWorld, self).options(parser, env=env)
def configure(self, options, conf):
super(HelloWorld, self).configure(options, conf)
if not self.enabled:
return
def finalize(self, result):
log.info('Hello pluginized world!')
然后就可以使用上面刚写好的插件过滤我们不想要的测试用例
1、直接导入使用
from nose import run
path=os.path.join(os.path.dirname(__file__)