python - how to manage sys.path globally in pycharm -
i have bunch of unittests import stuff not /python2.7/site-packages/ different directory. do monkey-patching in each test file sys.path.append make python see need.
is there way append sys.path globally whole pycharm project without bothering each , every file?
update: setting default working directory doesn't help. example, if set working directory /users/1111/_projects/_empty_dir/ so:

and run this
import sys p in sys.path: print p what see this
/users/1111/.virtualenvs/blesk/bin/python /users/1111/_projects/_testing_pycharm/importer.py /users/1111/_projects/_testing_pycharm /users/1111/.virtualenvs/blesk/lib/python2.7/site-packages/six-1.9.0-py2.7.egg /users/1111/.virtualenvs/blesk/lib/python2.7/site-packages/parse-1.6.6-py2.7.egg /users/1111/_projects/_testing_pycharm /users/1111/.virtualenvs/blesk/lib/python27.zip /users/1111/.virtualenvs/blesk/lib/python2.7 /users/1111/.virtualenvs/blesk/lib/python2.7/plat-darwin /users/1111/.virtualenvs/blesk/lib/python2.7/plat-mac /users/1111/.virtualenvs/blesk/lib/python2.7/plat-mac/lib-scriptpackages /users/1111/.virtualenvs/blesk/lib/python2.7/lib-tk /users/1111/.virtualenvs/blesk/lib/python2.7/lib-old /users/1111/.virtualenvs/blesk/lib/python2.7/lib-dynload /library/frameworks/python.framework/versions/2.7/lib/python2.7 /library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin /library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk /library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac /library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /users/1111/.virtualenvs/blesk/lib/python2.7/site-packages process finished exit code 0 and there no /users/1111/_projects/_empty_dir/ on sys.path.
yes.
i on mac, using pycharm 4.5.1 professional edition. platform , version may bit different, if make sure on latest version, should work.
edit: i've updated answer , uploaded new screenshot.
what want set working directory and pythonpath environment variable.
the working directory sets directory used running task. , pythonpath environment variable adds directories sys.path
go run -> edit configurations
in dialog box comes up, navigate defaults -> python tests -> unittests
set working directory , pythonpath environment variable , set. tests automatically run working directory , have sys.path want. can include multiple paths in pythonpath environment variable if separate them colon :
for example:
pythonpath=/path/to/dir:/path/to/other/dir if have existing test configurations, may want delete them re-created when run tests or set working directory , pythonpath each of them. can delete them same dialog window
run -> edit configurations expand python tests see existing test configurations
if don't want delete existing test configurations, specify working directory each existing test configuration individually.

Comments
Post a Comment