7

I have a script which executes python unit tests. What this script does is firstly prepare the PYTHONPATH variable and then executes the python unit tests.

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

Vasil Daskalov
  • 121
  • 1
  • 7
  • I dont know how to set python path using a script in PyCharm, but I think you may get some ideas from this from: http://stackoverflow.com/questions/17198319/how-to-configure-custom-pythonpath-with-vm-and-pycharm – Guoliang May 10 '16 at 08:04
  • Doesn't "Edit Configurations" --> "Environment Variables" or "Before launch" cover your case? – mkaran May 10 '16 at 09:31
  • in "Environment Variables" you'd have to specify each variable separately, that is you can not use a script. "Before launch" is running the tasks in separate process – Vasil Daskalov May 10 '16 at 10:08
  • Pretty old question. Has no one got an answer yet? I'm wondering this too... – Hendrik Wiese Jun 16 '16 at 09:34

1 Answers1

0

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

An IntelliJ IDEA plugin to automatically add environment variables to Path Variables.

For example, you can have a file myproject.env with next content:

SOME_VAR=SOME_VALUE

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

grundic
  • 4,641
  • 3
  • 31
  • 47