How to run Python nose tests with a different version of Python

Jacek Furmankiewicz picture Jacek Furmankiewicz · Dec 16, 2010 · Viewed 7.5k times · Source

We have CentOS with the ancient Python 2.4 interpreter.

But we would like to write out tests with a newer 2.5/2.6 syntax.

Assuming we have a second Python interpreter installed (e.g. python2.6) is there any way to run the 'nosetests' shell command and tell it to use a specific python interpreter instead of the default one?

Answer

Thomas K picture Thomas K · Dec 16, 2010

The nosetests file is in Python, so it should just be a matter of running it in your new version. Find where the file is:

which nosetests

Then:

python2.6 /usr/bin/nosetests

Adjusting the name and path to match your system. I've not tested, but that should work.