Pycharm 不允许运行文件.仅显示运行 unittest 选项. [英] Pycharm won't allow to run a file. Shows run unittest option only.

查看:36
本文介绍了Pycharm 不允许运行文件.仅显示运行 unittest 选项.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,它有一堆以前缀test"开头的方法.现在我想运行这个文件,它有一个 __name__ == "__main__" 构造来设置它.但是,当我右键单击或转到运行菜单栏时,它(Pycharm)只显示在 xxx 中运行单元测试".这是非常烦人的行为.

I have a file and it has bunch of methods starting with prefix "test". Now I want to run this file and it has a __name__ == "__main__" construct which sets it up. However, when I right click or go to run menu bar, It (Pycharm) only shows me "Run Unittests in xxx". This is very annoying behaviour.

谁能告诉我如何避免这种情况.

Can someone please tell me how to avoid this.

推荐答案

如果你在 'if name == "ma​​in"' 块内右击,它将向您显示常规的运行脚本"选项而不是运行单元测试".之后,您可以保存创建的运行配置并使用它来运行脚本.

If you right-click inside the 'if name == "main"' block, it will show you the regular "Run script" option instead of "Run unit test". After that, you can save the created run configuration and use it to run the script.

这篇关于Pycharm 不允许运行文件.仅显示运行 unittest 选项.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆