Load environment variable from script in PyCharm

I have a script that runs python unit tests. What kind of script is this, firstly, you need to prepare the PYTHONPATH variable, and then run the python module tests.

Now I want to run my python tests in PyCharm, however I want to reuse a script that builds environment variables. Is there a way to tell a script to prepare env variables in the run / debug configuration in PyCharm?

+7
python pycharm python-unittest
source share
1 answer

You can use the env-vars-in-path-vars plugin for the IntelliJ IDEA family:

IntelliJ IDEA plugin for automatically adding environment variables to Path Variables.

For example, you can have a myproject.env file with the following contents:

 SOME_VAR=SOME_VALUE 

You can use this file from both your script and the IDE, using the plugin and changing the environment variables will be reflected in both.

0
source share

All Articles