[SciPy-Dev] reading a module under test

Ralf Gommers ralf.gommers at googlemail.com
Mon May 14 16:13:48 EDT 2012


On Mon, May 14, 2012 at 10:09 PM, Denis Laxalde <denis at laxalde.org> wrote:

> 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.
>

It should help. Check with $echo $PYTHONPATH that the dir you installed it
in comes before your site-packages dir. To achieve this, I have in my
.bash_login this:

export PYTHONPATH="$HOME/Code/numpy:$HOME/Code/scipy:${PYTHONPATH}"


> Is there a generic way to say something like
> >
> > from scipy import path_to_my_stats_under_test/stats    ?
>

Not really.


> > 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.
>
> Possible too, but not so handy if you want to edit in-place and then
commit the results.

Ralf

Then to run the tests, python -c "from scipy import stats; stats.test()".
>
> --
> Denis
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20120514/02c8f0ba/attachment.html>


More information about the SciPy-Dev mailing list