列出 Nosetest 找到的所有测试

发布于 2024-07-15 19:30:45 字数 100 浏览 5 评论 0原文

我使用 nosetests 来运行我的单元测试,它运行良好。 我想获得 nostests 发现的所有测试的列表,而无需实际运行它们。 有没有办法做到这一点?

I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that?

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

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

发布评论

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

评论(3

聽兲甴掵 2024-07-22 19:30:45

版本 0.11.1 目前可用。 您无需运行测试即可获取测试列表,如下所示:

nosetests -v --collect-only

Version 0.11.1 is currently available. You can get a list of tests without running them as follows:

nosetests -v --collect-only
倾其所爱 2024-07-22 19:30:45

我建议使用:

nosetests -vv --collect-only

虽然 -vv 选项在 man Nosetests 中没有描述,“nose 单元测试框架的扩展介绍” 指出:

使用 -vv 标志可以为您提供鼻子测试发现算法的详细输出。 这将告诉您鼻子是否在正确的位置寻找测试。

在尝试确定为什么osetests 只找到部分测试时,-vv 选项可以节省时间。 (就我而言,这是因为nosetests跳过了某些测试,因为.py脚本是可执行的。)

底线是-vv选项非常方便,我几乎始终使用它而不是 -v 选项。

I recommend using:

nosetests -vv --collect-only

While the -vv option is not described in man nosetests, "An Extended Introduction to the nose Unit Testing Framework" states that:

Using the -vv flag gives you verbose output from nose's test discovery algorithm. This will tell you whether or not nose is even looking in the right place(s) to find your tests.

The -vv option can save time when trying to determine why nosetests is only finding some of your tests. (In my case, it was because nosetests skipped certain tests because the .py scripts were executable.)

Bottom line is that the -vv option is incredibly handy, and I almost always use it instead of the -v option.

著墨染雨君画夕 2024-07-22 19:30:45

很快就会出现:上周在 PyCon 上演示了产生此行为的新 --collect 开关。 它应该“很快”就会出现在主干上,并将在 0.11 版本中发布。

https://groups.google.com/g/nose-users 列表为关于鼻子问题的一个很好的资源。

There will be soon: a new --collect switch that produces this behavior was demoed at PyCon last week. It should be on the trunk "soon" and will be in the 0.11 release.

The https://groups.google.com/g/nose-users list is a great resource for nose questions.

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