0

Is it possible to follow Good Integration as here http://pytest.org/latest/goodpractices.html in a package that depends on PyQt5 ? (I am using Ubuntu 14.04, don't know if this impacts)

I get the following with both suggested approaches:

$ python3 setup.py test
running test
Searching for pyqt5
Reading https://pypi.python.org/simple/pyqt5/
No local packages or download links found for pyqt5
error: Could not find suitable distribution for Requirement.parse('pyqt5')

I can pip3 install pyqt5, which is why I place pyqt5 in my setup.py. Also running py.test in the command line just works.

eri0o
  • 2,285
  • 4
  • 27
  • 43

1 Answers1

1

Running py.test in the command line performs the tests in your current Python environment.

Running python3 setup.py test (with pytest-runner in accordance with pytest's 'Good Integration Practices') creates a pseudo-virtualenv. It pulls in any missing dependencies as eggs (storing them in .eggs directory), then performs the test in the aforementioned environment.

To be clear, py.test and python3 setup.py test do different things.


To illustrate the difference between these two commands, here are a few scenarios:

py.test

  • py.test - launches pytest, your tests presumably fail because PyQt5 is not importable
  • pip3 install PyQt5 && py.test - install bdist_wheel of PyQt5 in the current environment then launches pytest, your tests presumably succeed

pytest-runner

  • python3 setup.py test - launch pytest-runner, checks dependencies in setup.py, determines that PyQt5 is not available, attempts to pull in an egg (but is unable to as PyQt5 is only available as a bdist_wheel, not a source distribution), then spits out an error message and exits
  • pip3 install PyQt5 && python3 setup.py test - install bdist_wheel of PyQt5 in the current environment then launches pytest-runner, checks dependencies in setup.py, determines that all dependencies are available, launches pytest, and your tests presumably succeed

The simple answer is no, it's not possible to do what you're asking. One way or another, you need to install PyQt5 into the environment prior to running tests.

Six
  • 5,122
  • 3
  • 29
  • 38
  • Could I create a virtual env without source? I feel sources shouldn't be required. I am using python3 and think I have seen pyenv or venv available. – eri0o Jul 08 '16 at 09:58
  • You can install PyQt5 into a virtual environment no problem. Then with it activated, run your tests like normal. I assume you're running Python 3.5.x, right? If so, you can create one with `python3 -m venv env` then activate it and install PyQt5 into it. Or you can install virtualenv and use that. I wouldn't bother with pyenv unless you need to switch between different versions of Python. – Six Jul 08 '16 at 10:15
  • Thank you. I will try that. It's Python 3.5.2 I think, I am going to be away from my computer for two days. – eri0o Jul 08 '16 at 10:25