Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 700
Vladimir Keleshev Avatar asked Dec 01 '11 09:12

Vladimir Keleshev


People also ask

How do I run a pytest from a specific version of Python?

To run Pytest inside your virtual environment, first install it using python -m pip install pytest and then run python -m pytest .

What version of Python is pytest using?

pytest requires: Python 3.7+ or PyPy3.

Can I use different versions of Python?

Yes, you should be able to switch between python versions. As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed.

Is pytest included in Python?

As most Python packages, pytest is available on PyPI. You can install it in a virtual environment using pip : Windows. Linux + macOS.


1 Answers

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.

like image 174
Jack O'Connor Avatar answered Sep 24 '22 08:09

Jack O'Connor