如何从Pycharm运行nosetest?
如何从pycharm执行nosetest来运行所有单元测试?
我知道 pycharm 支持 python 的unittest和py.test,并且它们将在pycharm 1.1中正确支持nosetests,但我想知道是否有解决方法。
How do you execute nosetest from pycharm to run all unit tests?
I know that pycharm supports python's unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wondering if there was a work around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在当前版本的 Pycharm (2.6) 中,测试文件上应该有一个上下文菜单“在...中运行 Nosetests”。如果缺少此选项,请转到
文件 -> 设置 -> 项目设置 -> python 集成工具
并确保默认测试运行程序为 Nosetests。您当然需要安装 Nosetests - 如果您没有安装,pycharm 会提供此功能。这确实有一个限制。如果相关文件没有从 unittest.TestCase 派生的类,它将不会自动显示这一点。如果您使用nose.tools或简单的断言,它不会自动提供此功能。这可能是一个错误。
In the current version of Pycharm (2.6) there should be a context menu "run Nosetests in ..." on a test file. If this is missing, go to
file->settings->Project Settings->python integrated tools
and ensure the Default Test Runner is Nosetests. You do of course need to have Nosetests installed - pycharm will offer this if you do not.This does have a limitation. If the file in question does not have a class derived from unittest.TestCase it will not automatically show this. If you are using nose.tools or simple assertions it will not automatically offer this. This is probably a bug.
如果您可以不用图形测试运行器,则只需创建一个“Python 脚本”运行配置并在从命令行运行测试时运行测试即可。
恐怕,让鼻子测试与图形测试运行器一起使用的唯一方法是破解 PyCharm 发行版中的 helpers/pycharm/utrunner.py 。
If you can live without the graphical test runner, you can simply create a "Python Script" run configuration and run the tests as you run them from the command line.
The only way to get nose tests working with the graphical test runner, I'm afraid, is to hack on helpers/pycharm/utrunner.py from the PyCharm distribution.
这很容易完成......
我假设你已经安装了鼻子。
并且您的项目看起来像
我们需要创建一个 Tests 目录(是的,名称似乎很关键)。在该 Tests 文件夹中,我们放置鼻子测试文件。所以目录结构看起来像这样。
此时您需要进入
首选项->工具-> Python集成工具**并将**默认测试运行程序设置为nose
您现在应该能够
使用nose手动
测试第二种方法是最好的选择,但可能会有点耗时。
希望有帮助。
This is easy to accomplish....
I assume you have nose already installed.
And that your project looks like
We need to Create a Tests directory (Yes the name seems to be critical). And in that Tests folder we place our nose test file. So the Directory structure looks like this.
At this point you need to go to
Preferences-> Tools -> Python Intergrated Tools ** and set **Default Test Runner to be nose
You should now be able to
Manually
The 2nd way is the best option, but it can be a little time consuming.
Hope that helps.