简体   繁体   English

列出Nosetest发现的所有测试

[英]List all Tests Found by Nosetest

I use nosetests to run my unittests and it works well. 我使用nosetests来运行我的单元测试,它运行良好。 I want to get a list of all the tests nostests finds without actually running them. 我想所有的测试列表nostests发现没有实际运行它们。 Is there a way to do that? 有没有办法做到这一点?

Version 0.11.1 is currently available. 版本0.11.1目前可用。 You can get a list of tests without running them as follows: 您可以在不运行测试的情况下获取测试列表,如下所示:

nosetests -v --collect-only

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: 虽然man nosetests 测试中没有描述-vv选项,但“单元测试框架的扩展简介”指出:

Using the -vv flag gives you verbose output from nose's test discovery algorithm. 使用-vv标志可以获得nose的测试发现算法的详细输出。 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. -vv选项可以在尝试确定为什么nosetests只找到一些测试时节省时间。 (In my case, it was because nosetests skipped certain tests because the .py scripts were executable.) (就我而言,这是因为nosetests跳过了某些测试,因为.py脚本是可执行的。)

Bottom line is that the -vv option is incredibly handy, and I almost always use it instead of the -v option. 底线是-vv选项非常方便,我几乎总是使用它而不是-v选项。

There will be soon: a new --collect switch that produces this behavior was demo'd at PyCon last week. 很快就会出现:上周在PyCon演示了一个产生这种行为的新的--collect开关。 It should be on the trunk "soon" and will be in the 0.11 release. 它应该在“很快”的主干上,并将在0.11版本中。

The http://groups.google.com/group/nose-users list is a great resource for nose questions. http://groups.google.com/group/nose-users列表是鼻子问题的绝佳资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM