Python 使用摊铺机和机头以及非典型目录结构
我正在尝试为Python 使用摊铺机和机头以及非典型目录结构,python,nose,paver,Python,Nose,Paver,我正在尝试为Paver编写一个任务,该任务将在我的文件上运行nosetests 我的目录结构如下所示: project/ file1.py file2.py file3.py build/ pavement.py subproject/ file4.py test/ file5.py file6.py 应在所有*.py文件上运行Doctests(使用--with_doctest选项),而只应在project/t
Paver
编写一个任务,该任务将在我的文件上运行nosetests
我的目录结构如下所示:
project/
file1.py
file2.py
file3.py
build/
pavement.py
subproject/
file4.py
test/
file5.py
file6.py
应在所有*.py文件上运行Doctests(使用--with_doctest
选项),而只应在project/test
下的文件(在本例中,file5.py
和file6.py
中)中搜索测试例程
我似乎不知道如何做到这一点——我可以为nose
编写一个自定义插件,其中包含正确的文件,但在调用nosetests
任务之前,我似乎无法让paver
构建并安装它。我也找不到方法让paver
将要测试的文件列表传递到命令行上的nosetests
什么是实现这一目标的最佳方法?这是否接近你想要达到的目标
from paver.easy import sh, path
__path__ = path(__file__).abspath().dirname()
@task
def setup_nose_plugin():
# ... do your plugin setup here.
@task
@needs('setup_nose_plugin')
def nosetests():
nose_options = '--with-doctest' # Put your command-line options in there
sh('nosetests %s' % nose_options,
# Your pavement.py is in a weird place, so you need to specify the working dir:
cwd=__path__.parent)
实际上,我不确定如何告诉nose查看特定文件,但这是命令行选项的问题
——其中
允许您指定一个目录,但我看不到一种方式可以说“在这里只运行doctests,在这里运行其他测试”。您可能需要两次调用sh('nosetests')
来完成所有这些