Search code examples
pythonunit-testingincludeinclude-path

Python: Add to Include Path on the Command Line


Is there a way to add include paths to python on the command line? What I am trying to do is run a unit test that uses a some code in a lib directory:

$ python -I lib/ test/my-test.py

but this fails. I can append to my path in my-test.py but that seems less than optimal since its path dependent. Any suggestions?


Solution

  • Use the PYTHONPATH environment variable:

    PYTHONPATH=lib/ python test/my-test.py