Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

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

like image 327
this.myself Avatar asked Apr 21 '15 16:04

this.myself


1 Answers

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

isRunningInPyCharm = "PYCHARM_HOSTED" in os.environ
like image 131
yole Avatar answered Oct 06 '22 17:10

yole