Distutils and unit test files

Cédric Lucantis omer at no-log.org
Mon Jun 23 10:24:40 EDT 2008


> On Mon, Jun 23, 2008 at 9:59 AM, Cédric Lucantis <omer at no-log.org> wrote:
> > Yes a checksuite should be kept separate from the 'real' code. You can
> > run it locally by setting the PYTHONPATH environment variable :
> >
> > PYTHONPATH=/path/to/your/modules python checksuite.py
>
> So I could also just append the path to sys.path in checksuite.py file
> and use checksuite to run all my unit tests?
>

(woops, sorry for the private post :)

Yes this is equivalent, as sys.path is initialized from PYTHONPATH at startup. 
But I'd suggest to insert your path at the beginning of sys.path rather than 
appending it, so you'll be sure to use the local modules even if they are 
already installed (I use 1 instead of 0 because sys.path[0] has a special 
meaning) :

sys.path.insert(1, '/path/...')

But I prefer to use PYTHONPATH, so the user keeps control on it (and can 
eventually check installed modules too). If you don't want to have to set it 
at each run, you can still write a simple wrapper script for your own needs.

-- 
Cédric Lucantis



More information about the Python-list mailing list