[英]Tests failed while updated pytest-qt v3.1.0 fixture qtmodeltester.check explicitly testing string_types for DisplayRole
pytest-qt v3.1.0顯式測試string_types是否顯示數據的DisplayRole。 對於較舊的版本則不是這種情況。 它破壞了我們的測試,因為我們返回了我們認為合理的數據DispalyRole的對象(int,str等)(不是嗎?)。
任何人都可以分享一下,如果您知道為什么會這樣?
技術:Python 2.7.x x64和Pyside v1.2.4操作系統:Windows 7計算機
def _test_data(self):
"""Test model's implementation of data()"""
if not self._has_children():
return
# A valid index should have a valid QVariant data
assert self._model.index(0, 0).isValid()
string_types = [str]
if sys.version_info.major == 2:
string_types.append(unicode) # noqa
if qt_api.QString is not None:
string_types.append(qt_api.QString)
string_types = tuple(string_types)
types = [
(qt_api.QtCore.Qt.DisplayRole, string_types),
(qt_api.QtCore.Qt.ToolTipRole, string_types),
(qt_api.QtCore.Qt.StatusTipRole, string_types),
(qt_api.QtCore.Qt.WhatsThisRole, string_types),
(qt_api.QtCore.Qt.SizeHintRole, qt_api.QtCore.QSize),
(qt_api.QtCore.Qt.FontRole, qt_api.QtGui.QFont),
(
qt_api.QtCore.Qt.BackgroundColorRole,
(qt_api.QtGui.QColor, qt_api.QtGui.QBrush),
),
(
qt_api.QtCore.Qt.TextColorRole,
(qt_api.QtGui.QColor, qt_api.QtGui.QBrush),
),
(
qt_api.QtCore.Qt.DecorationRole,
(
qt_api.QtGui.QPixmap,
qt_api.QtGui.QImage,
qt_api.QtGui.QIcon,
qt_api.QtGui.QColor,
qt_api.QtGui.QBrush,
),
),
]
# General purpose roles with a fixed expected type
for role, typ in types:
data = self._model.data(self._model.index(0, 0), role)
if data is not None:
data = qt_api.extract_from_variant(data)
assert data == None or isinstance(data, typ), role # noqa
AssertionError: PySide.QtCore.Qt.ItemDataRole.DisplayRole
assert (1 == None or False)
where False = isinstance(1, (<type 'str'>, <type 'unicode'>))
.tox\py27\lib\site-packages\pytestqt\modeltest.py:499: AssertionError
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.