1

我正在使用 AppVeyor(Think Travis,但适用于 Windows)再次运行几个不同版本的 Python 的一些测试。测试依赖于 PyQt 和 pytest-qt。在某些配置中,pytest-qt 找不到 PyQt,抱怨:

pytest-qt 需要安装 PySide、PySide2、PyQt4 或 PyQt5

PyQt5 测试正在运行,但测试还需要运行需要 PyQt4 的旧版 Python。

Python 2.7,32 位

在 Python 2.7(32 位)上,我使用 conda 安装 PyQt:

conda install -q pyqt=4

它成功安装了pyqt-4.11.4-py27_7

然后我用 pip 安装 pytest-qt:

pip install pytest pytest-cov pytest-qt

它成功安装了 pytest-qt-2.4.0。

然后我运行测试。没关系。

Python 2.7,64 位

完全一样的故事。工作正常。

Python 3.4,64 位

这次它安装了pyqt 4.11.4-py34_7,加上相同版本的pytest-qt,但是在测试运行时,它崩溃了:

py.test tests -v
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\_pytest\main.py", line 174, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\_pytest\config.py", line 957, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 628, in call_historic
INTERNALERROR>     res = self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pluggy\callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pytestqt\plugin.py", line 187, in pytest_configure
INTERNALERROR>     qt_api.set_qt_api(config.getini('qt_api'))
INTERNALERROR>   File "c:\miniconda34-x64\lib\site-packages\pytestqt\qt_compat.py", line 60, in set_qt_api
INTERNALERROR>     raise RuntimeError(msg)
INTERNALERROR> RuntimeError: pytest-qt requires either PySide, PySide2, PyQt4 or PyQt5 to be installed
Command exited with code 3

我尝试指定环境变量PYTEST_QT_API=pyqt4or PYTEST_QT_API=pyqt4v2,但它抱怨:

ImportError:DLL 加载失败:找不到指定的模块。

我不知道 Python 3.4 可能有什么不同。我需要做些什么来帮助 pytest-qt 找到 PyQt 的安装?

4

0 回答 0