开发者

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

We have CentOS with the ancient Python 2.4 interpreter.

But we would like to write out tests wit开发者_运维问答h 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?


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.


Well, what I'd do is to install a different version of Python (2.6 say) and then create a virtualenv and install nose inside that. It will then use that version of nose and keep your stuff isolated.

You can also consider using tox to try to bridge interpreters.

Finally, you can simply run nose python2.6 $(which nose) [other options] args to run nose with the newer Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜