Pytest and Python 3

In addition to the aforementioned python3 -m pytest, this might also work:

env pytest

I found a workaround:

  1. Installed python3-pip using aptitude, which created /usr/bin/pip-3.2.
  2. Next pip-3.2 install pytest which re-installed pytest, but under a python3.2 path.
  3. Then I was able to use python3 -m pytest somedir/sometest.py.

Not as convenient as running py.test directly, but workable.


This worked for me:

python3 $(which py.test) ...

python3 doesn't have the module py.test installed. If you can, install the python3-pytest package.

If you can't do that try this:

  1. Install virtualenv
  2. Create a virtualenv for python3
    • virtualenv --python=python3 env_name
  3. Activate the virtualenv
    • source ./env_name/bin/activate
  4. Install py.test
    • pip install py.test
  5. Now using this virtualenv try to run your tests

Tags:

Pytest