How to run py.test against different versions of python?

烂漫一生 提交于 2019-12-05 09:27:19

问题


Is it possible to run py.test with different versions of python without plugins (like xdist) or tox?


回答1:


The simplest way to do it is by running the pytest module directly with -m, for example:

python2.6 -m pytest

Note that you have to have pytest installed for that version of Python. In addition, you need to install all pytest plugins that you are using for that version of Python too.




回答2:


You can create a standalone pytest script with

py.test --genscript=mypytest

and then do

pythonXY mypytest 

to run tests with a particular python version.

You do not need to install pytest for that particular python version as pytest is completely contained in the "mypytest" script.




回答3:


VirtualEnv is done to handle those case.

virtualenv is a tool to create isolated Python environments.

Using virtualenv, you will be able to create multiple environements, each one with one plugin you want.




回答4:


Using xdist plugin this can be easily done:

py.test -d --tx popen//python=pythonX

runs python version X (2 or 3).


Since this is the first google result of "pytest test multiple versions" I'm posting this, nevertheless I realize this is not an answer to OP's question of how to do this without plugins.



来源:https://stackoverflow.com/questions/8338854/how-to-run-py-test-against-different-versions-of-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!