2

I have both Python 2.7 and 3.3 installed on a Mac. I'm trying to get Pytest to run my tests under Python 3.3.

When I run python3 –m py.test it halts, looking for the libs under the 3.3 path.

When I run pip install –U pytest it installs to the 2.7 path.

I've seen the write-ups for Virtualenv, but I'm not ready to go there yet.

Is there another way?

1

2 Answers 2

1

Take a look at the tox project. It helps you to test your code under different python versions and interpreters.

Example tox.ini config for your case:

[tox]
envlist = py27,py33
[testenv]
deps = pytest
commands = py.test

It's not a silver bullet but it will definitely help to automate your tedious test activities.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Tox looks cool. But i'm hoping to find a solution that doesn't have me adding to the stack just yet. I'm sure i will soon, but right now going for minimal viable solution.
1

Apart from the genscript option the normal way to go about this is to intall py.test into the python3.3 interpreter's environment. The problem you have is that the pip you invoke is also a py27 version, so it will install into py27.

So you can start with installing pip into py33 (usually under the alias pip3) and then invoking that pip or you can simply install py and pytest in the py33 environment the old fashioned way: download the packages and run python3.3 setup.py install --user.

You will then still want to make sure you can invoke the correct version of py.test however, either making sure you can call py.test and py.test3 using aliases or so. Or simply by using pythonX.Y -m pytest.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.