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.