[SciPy-Dev] reading a module under test

Denis Laxalde denis at laxalde.org
Mon May 14 16:09:37 EDT 2012


nicky van foreest a écrit :
> I would like to run a test on some code in my local branch of scipy.
> Now the problem in one of the test files is that it says
>
> from scipy import stats
>
> Now this reads the standard stats module, not the one I want to test,
> i.e, the one on my local branch. I changed the pythonpath, but this
> does not help. Is there a generic way to say something like
>
> from scipy import path_to_my_stats_under_test/stats    ?
>
> Specifically, I want to load this file:
> /home/nicky/prog/scipy/scipy/stats/distributions.py, and I don't want
> to load /usr/lib/python2.7/dist-packages/scipy/stats/distributions.py.

You could build scipy from source and install it under your home 
directory using (from the root directory of sources):

     python setup.py install --user

This will (on UNIX-like systems) install scipy in 
.local/lib/python2.7/site-packages/scipy. This directory comes before 
/usr/lib/python2.7/dist-packages so no need to tweak the PYTHONPATH.

Then to run the tests, python -c "from scipy import stats; stats.test()".

-- 
Denis



More information about the SciPy-Dev mailing list