简体   繁体   English

如何检查python单元测试是否在PyCharm中启动?

[英]How to check if python unit test started in PyCharm or not?

Is there a way to check in a python unit test (or any other script) if it is executed inside the PyCharm IDE or not? 有没有办法检查python单元测试(或任何其他脚本),如果它是在PyCharm IDE内部执行?

I would like to do some special things in a unit test when it started locally, things I would not like to do when the whole thing is execute on the build server. 我想在本地启动时在单元测试中做一些特殊的事情,当整个事情在构建服务器上执行时我不想做的事情。

Cheers 干杯

在PyCharm下运行时,定义了PYCHARM_HOSTED环境变量。

isRunningInPyCharm = "PYCHARM_HOSTED" in os.environ

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

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