Pycharm won#39;t allow to run a file. Shows run unittest option only.(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 == "main"' 块内右击,它将向您显示常规的运行脚本"选项而不是运行单元测试".之后,您可以保存创建的运行配置并使用它来运行脚本.
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 选项.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Pycharm 不允许运行文件.仅显示运行 unittest 选项
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
