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?

4
  • I dont know how to set python path using a script in PyCharm, but I think you may get some ideas from this from: stackoverflow.com/questions/17198319/… Commented May 10, 2016 at 8:04
  • Doesn't "Edit Configurations" --> "Environment Variables" or "Before launch" cover your case? Commented May 10, 2016 at 9: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 Commented May 10, 2016 at 10:08
  • Pretty old question. Has no one got an answer yet? I'm wondering this too... Commented Jun 16, 2016 at 9:34

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.