How to check if python unit test started in PyChar

2020-02-12 03:18发布

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?

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

1条回答
戒情不戒烟
2楼-- · 2020-02-12 04:05

When running under PyCharm, the PYCHARM_HOSTED environment variable is defined.

isRunningInPyCharm = "PYCHARM_HOSTED" in os.environ
查看更多
登录 后发表回答