pytest 不与 PySide 一起工作
pytest not working with PySide
pytest 似乎忽略了使用 PySide 的测试。
例如,我有一个文件 test_pyside.py,内容为
from PySide import QtGui
def test_dialog():
dialog = QtGui.QDialog()
assert False
运行 python -m pytest test_pyside.py 的输出是:
============================ test session starts ============================
platform win32 -- Python 2.7.12, pytest-3.0.5, py-1.4.31, pluggy-0.4.0 rootdir: C:\Users\erik, inifile:
collected 1 items
就是这样。没有错误报告。不知道为什么。
您的测试段错误是因为它创建了 QDialog
而没有创建 QApplication
。我建议使用 pytest-qt 插件来为您解决这个问题。
pytest 似乎忽略了使用 PySide 的测试。 例如,我有一个文件 test_pyside.py,内容为
from PySide import QtGui
def test_dialog():
dialog = QtGui.QDialog()
assert False
运行 python -m pytest test_pyside.py 的输出是:
============================ test session starts ============================ platform win32 -- Python 2.7.12, pytest-3.0.5, py-1.4.31, pluggy-0.4.0 rootdir: C:\Users\erik, inifile: collected 1 items
就是这样。没有错误报告。不知道为什么。
您的测试段错误是因为它创建了 QDialog
而没有创建 QApplication
。我建议使用 pytest-qt 插件来为您解决这个问题。