将摊铺机和鼻子与非典型目录结构一起使用

发布于 2024-07-17 04:45:25 字数 678 浏览 9 评论 0原文

我正在尝试为 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

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

I'm trying to write a task for Paver that will run nosetests on my files.

My directory structure looks like this:

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

Doctests (using the --with_doctest option) should be run on all the *.py files, while only the files under project/test (in this example, file5.py and file6.py) should be searched for test routines.

I can't seem to figure out how to do this--I can write a custom plugin for nose which includes the correct files, but I can't seem to get paver to build and install it before calling the nosetests task. I also can't find a way to get paver to pass a list of files to test to nosetests on the command line.

What's the best way of getting this to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪荡不羁 2024-07-24 04:45:25

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

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

Is this at all close to what you're trying to get at?

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)

I'm not actually sure how to tell nose to look in specific files, but that's a matter of command-line options.

--where lets you specify a directory, but I don't see a way to say "run only doctests here, and other tests here". You may need two invocations of sh('nosetests') to do all that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文