Is it possible to run py.test
with different versions of python without plugins (like xdist
) or tox
?
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.
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.
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.
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