Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用摊铺机和机头以及非典型目录结构_Python_Nose_Paver - Fatal编程技术网

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')
来完成所有这些