3

我正在尝试编写一个将在我的文件上Paver运行的任务。nosetests

我的目录结构如下所示:

project/
   file1.py
   file2.py
   file3.py
   build/
      pavement.py
   subproject/
      file4.py
   test/
      file5.py
      file6.py

Doctests(使用该--with_doctest选项)应该在所有 *.py 文件上运行,而只有project/test(在这个例子中,file5.pyfile6.py)下的文件应该被搜索测试例程。

我似乎无法弄清楚如何做到这一点——我可以编写一个包含正确文件的自定义插件,但在调用任务之前nose我似乎无法paver构建和安装它。nosetests我也找不到在命令行上paver传递要测试的文件列表的方法。nosetests

让它发挥作用的最佳方法是什么?

4

1 回答 1

2

这完全接近你想要达到的目标吗?

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)

我实际上不确定如何告诉鼻子查看特定文件,但这是命令行选项的问题。

--where让您指定一个目录,但我看不到“仅在此处运行 doctests,在此处运行其他测试”的方法。您可能需要两次调用sh('nosetests')来完成所有这些操作。

于 2009-12-21T22:15:04.587 回答