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 选项
基础教程推荐
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
