aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-04-22 16:43:25 +0200
committerChristian Tismer <tismer@stackless.com>2017-04-28 12:21:38 +0000
commit7d1307d6d954380b1181309ecc73f1e3a2f8e003 (patch)
tree4f44a5bb4c7a58282dea8a0972c3a433d92d990f
parent04457b7c819b325ace3311f3f5f6189f4bd9d5da (diff)
Support Gentoo’s minimalism: Optional Modules
It has been reported that Gentoo is quite minimalistic and adheres strictly to Qt5’s definition of optional modules. Because I once used the Qt5 essential modules as the minimum requirement, the Gentoo maintainers had to always patch out makefiles This patch removes this restriction. But instead simply removing, I added an option “essential” to the ‘CHECK_PACKAGE_FOUND’ macro. When an essential module is omitted, the macro generates a warning that maybe not all tests are working. This way, we don’t have to check all tests at once for missing imports. Update: application_test now correctly moved. Explicit warning for essential modules. Corrections, tested with QtCore, only. Task-number: PYSIDE-502 Change-Id: I6e63c74c80173e0f4bcb5100458b37963f71e4f9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--PySide2/CMakeLists.txt18
-rw-r--r--tests/QtCore/bug_PYSIDE-42.py1
-rw-r--r--tests/QtWidgets/CMakeLists.txt1
-rw-r--r--tests/QtWidgets/application_test.py (renamed from tests/pysidetest/application_test.py)0
-rw-r--r--tests/pysidetest/CMakeLists.txt3
-rw-r--r--tests/pysidetest/new_inherited_functions_test.py173
-rw-r--r--tests/pysidetest/typesystem_pysidetest.xml2
7 files changed, 118 insertions, 80 deletions
diff --git a/PySide2/CMakeLists.txt b/PySide2/CMakeLists.txt
index db602c0e..8679929e 100644
--- a/PySide2/CMakeLists.txt
+++ b/PySide2/CMakeLists.txt
@@ -54,6 +54,9 @@ macro(CHECK_PACKAGE_FOUND name)
else()
if("${ARGN}" STREQUAL "opt")
message(STATUS "optional module ${name} skipped")
+ elseif("${ARGN}" STREQUAL "essential")
+ message(STATUS "skipped optional module ${name} is essential!\n"
+ " We do not guarantee that all tests are working.")
else()
message(FATAL_ERROR "module ${name} MISSING")
endif()
@@ -116,19 +119,18 @@ macro(skip_missing_classes sources)
endmacro()
CHECK_PACKAGE_FOUND(Qt5Core)
-CHECK_PACKAGE_FOUND(Qt5Concurrent)
-CHECK_PACKAGE_FOUND(Qt5Gui)
-CHECK_PACKAGE_FOUND(Qt5Widgets)
-CHECK_PACKAGE_FOUND(Qt5PrintSupport)
+CHECK_PACKAGE_FOUND(Qt5Concurrent essential)
+CHECK_PACKAGE_FOUND(Qt5Gui essential)
+CHECK_PACKAGE_FOUND(Qt5Widgets essential)
+CHECK_PACKAGE_FOUND(Qt5PrintSupport essential)
CHECK_PACKAGE_FOUND(Qt5Xml)
CHECK_PACKAGE_FOUND(Qt5XmlPatterns opt)
CHECK_PACKAGE_FOUND(Qt5Svg opt)
-CHECK_PACKAGE_FOUND(Qt5PrintSupport)
-CHECK_PACKAGE_FOUND(Qt5Sql)
+CHECK_PACKAGE_FOUND(Qt5Sql essential)
CHECK_PACKAGE_FOUND(Qt5Designer opt)
CHECK_PACKAGE_FOUND(Qt5UiTools opt)
-CHECK_PACKAGE_FOUND(Qt5Test)
-CHECK_PACKAGE_FOUND(Qt5Network)
+CHECK_PACKAGE_FOUND(Qt5Test essential)
+CHECK_PACKAGE_FOUND(Qt5Network essential)
CHECK_PACKAGE_FOUND(Qt5WebKit opt)
CHECK_PACKAGE_FOUND(Qt5WebKitWidgets opt)
CHECK_PACKAGE_FOUND(Qt5Script opt)
diff --git a/tests/QtCore/bug_PYSIDE-42.py b/tests/QtCore/bug_PYSIDE-42.py
index 1e3f0f1d..15b6fead 100644
--- a/tests/QtCore/bug_PYSIDE-42.py
+++ b/tests/QtCore/bug_PYSIDE-42.py
@@ -27,7 +27,6 @@
#############################################################################
from PySide2.QtCore import *
-from PySide2.QtWidgets import *
import unittest
class TestBugPYSIDE42 (unittest.TestCase):
diff --git a/tests/QtWidgets/CMakeLists.txt b/tests/QtWidgets/CMakeLists.txt
index c70715d8..3c31b1d7 100644
--- a/tests/QtWidgets/CMakeLists.txt
+++ b/tests/QtWidgets/CMakeLists.txt
@@ -3,6 +3,7 @@
PYSIDE_TEST(action_clear.py)
PYSIDE_TEST(add_action_test.py)
PYSIDE_TEST(api2_test.py)
+PYSIDE_TEST(application_test.py)
PYSIDE_TEST(bug_172.py)
PYSIDE_TEST(bug_243.py)
PYSIDE_TEST(bug_307.py)
diff --git a/tests/pysidetest/application_test.py b/tests/QtWidgets/application_test.py
index 78628a55..78628a55 100644
--- a/tests/pysidetest/application_test.py
+++ b/tests/QtWidgets/application_test.py
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt
index 91bac030..3a5437e6 100644
--- a/tests/pysidetest/CMakeLists.txt
+++ b/tests/pysidetest/CMakeLists.txt
@@ -98,9 +98,8 @@ target_link_libraries(testbinding
${Qt5Widgets_LIBRARIES}
${SBK_PYTHON_LIBRARIES})
-add_dependencies(testbinding pyside2 QtCore QtGui QtWidgets libpyside pysidetest)
+add_dependencies(testbinding pyside2 QtCore libpyside pysidetest)
-PYSIDE_TEST(application_test.py)
PYSIDE_TEST(decoratedslot_test.py)
PYSIDE_TEST(delegatecreateseditor_test.py)
PYSIDE_TEST(enum_test.py)
diff --git a/tests/pysidetest/new_inherited_functions_test.py b/tests/pysidetest/new_inherited_functions_test.py
index 3c758202..bd5db766 100644
--- a/tests/pysidetest/new_inherited_functions_test.py
+++ b/tests/pysidetest/new_inherited_functions_test.py
@@ -33,13 +33,16 @@ import os
import unittest
import PySide2.QtCore
-import PySide2.QtGui
-import PySide2.QtWidgets
-import PySide2.QtPrintSupport
# This test tests the existence and callability of the newly existing functions,
# after the inheritance was made complete in the course of PYSIDE-331.
+def warn_essential(modname):
+ print(80 * "*")
+ print("*** Warning: '{}' is an essential module! Are you sure to skip it?"
+ .format(modname))
+ print(80 * "*")
+
new_functions = """
PySide2.QtCore.QAbstractItemModel().parent()
PySide2.QtCore.QAbstractListModel().parent()
@@ -48,51 +51,71 @@ new_functions = """
m = PySide2.QtCore.QMutex(); m.tryLock(); m.unlock() # prevent a message "QMutex: destroying locked mutex"
PySide2.QtCore.QSortFilterProxyModel().parent()
PySide2.QtCore.QTemporaryFile(tfarg).open(openMode)
- PySide2.QtGui.QBitmap().transformed(qMatrix,transformationMode)
- PySide2.QtGui.QStandardItemModel().insertColumn(int,qModelIndex)
- PySide2.QtGui.QStandardItemModel().insertRow(int,qModelIndex)
- PySide2.QtGui.QStandardItemModel().parent()
- # PySide2.QtGui.QTextList(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
- # PySide2.QtGui.QTextTable(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
- PySide2.QtWidgets.QAbstractItemView().update()
- PySide2.QtWidgets.QApplication.palette()
- PySide2.QtWidgets.QApplication.setFont(qFont)
- PySide2.QtWidgets.QApplication.setPalette(qPalette)
- PySide2.QtWidgets.QBoxLayout(direction).addWidget(qWidget)
- PySide2.QtWidgets.QColorDialog().open()
- PySide2.QtWidgets.QDirModel().index(int,int,qModelIndex)
- PySide2.QtWidgets.QDirModel().parent()
- PySide2.QtWidgets.QFileDialog().open()
- PySide2.QtWidgets.QFileSystemModel().index(int,int,qModelIndex)
- PySide2.QtWidgets.QFileSystemModel().parent()
- PySide2.QtWidgets.QFontDialog().open()
- PySide2.QtWidgets.QGestureEvent([]).accept()
- PySide2.QtWidgets.QGestureEvent([]).ignore()
- PySide2.QtWidgets.QGestureEvent([]).isAccepted()
- PySide2.QtWidgets.QGestureEvent([]).setAccepted(bool)
- # PySide2.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags) # QPaintDevice: NotImplementedError
- PySide2.QtWidgets.QGridLayout().addWidget(qWidget)
- PySide2.QtWidgets.QHeaderView(orientation).initStyleOption(qStyleOptionFrame)
- PySide2.QtWidgets.QInputDialog().open()
- PySide2.QtWidgets.QLineEdit().addAction(qAction)
- PySide2.QtWidgets.QListWidget().closePersistentEditor(qModelIndex)
- PySide2.QtWidgets.QListWidget().openPersistentEditor(qModelIndex)
- PySide2.QtWidgets.QMessageBox().open()
- PySide2.QtWidgets.QPlainTextEdit.find(quintptr)
- PySide2.QtWidgets.QProgressDialog().open()
- PySide2.QtWidgets.QStackedLayout().widget()
- # PySide2.QtWidgets.QStylePainter().begin(qPaintDevice) # QPaintDevice: NotImplementedError
- PySide2.QtWidgets.QTableWidget().closePersistentEditor(qModelIndex)
- PySide2.QtWidgets.QTableWidget().openPersistentEditor(qModelIndex)
- PySide2.QtWidgets.QTextEdit.find(quintptr)
- PySide2.QtWidgets.QTreeWidget().closePersistentEditor(qModelIndex)
- PySide2.QtWidgets.QTreeWidget().openPersistentEditor(qModelIndex)
- # PySide2.QtPrintSupport.QPageSetupDialog().open() # Segmentation fault: 11
- # PySide2.QtPrintSupport.QPrintDialog().open() # opens the dialog, but works
- PySide2.QtPrintSupport.QPrintDialog().printer()
- PySide2.QtPrintSupport.QPrintPreviewDialog().open() # note: this prints something, but really shouldn't ;-)
"""
try:
+ modname = "PySide2.QtGui"
+ exec("import " + modname)
+ new_functions += """
+ PySide2.QtGui.QBitmap().transformed(qMatrix,transformationMode)
+ PySide2.QtGui.QStandardItemModel().insertColumn(int,qModelIndex)
+ PySide2.QtGui.QStandardItemModel().parent()
+ # PySide2.QtGui.QTextList(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
+ # PySide2.QtGui.QTextTable(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
+ """
+except ImportError:
+ warn_essential(modname)
+try:
+ modname = "PySide2.QtWidgets"
+ exec("import " + modname)
+ new_functions += """
+ PySide2.QtWidgets.QAbstractItemView().update()
+ PySide2.QtWidgets.QApplication.palette()
+ PySide2.QtWidgets.QApplication.setFont(qFont)
+ PySide2.QtWidgets.QApplication.setPalette(qPalette)
+ PySide2.QtWidgets.QBoxLayout(direction).addWidget(qWidget)
+ PySide2.QtWidgets.QColorDialog().open()
+ PySide2.QtWidgets.QDirModel().index(int,int,qModelIndex)
+ PySide2.QtWidgets.QDirModel().parent()
+ PySide2.QtWidgets.QFileDialog().open()
+ PySide2.QtWidgets.QFileSystemModel().index(int,int,qModelIndex)
+ PySide2.QtWidgets.QFileSystemModel().parent()
+ PySide2.QtWidgets.QFontDialog().open()
+ PySide2.QtWidgets.QGestureEvent([]).accept()
+ PySide2.QtWidgets.QGestureEvent([]).ignore()
+ PySide2.QtWidgets.QGestureEvent([]).isAccepted()
+ PySide2.QtWidgets.QGestureEvent([]).setAccepted(bool)
+ # PySide2.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags) # QPaintDevice: NotImplementedError
+ PySide2.QtWidgets.QGridLayout().addWidget(qWidget)
+ PySide2.QtWidgets.QHeaderView(orientation).initStyleOption(qStyleOptionFrame)
+ PySide2.QtWidgets.QInputDialog().open()
+ PySide2.QtWidgets.QLineEdit().addAction(qAction)
+ PySide2.QtWidgets.QListWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QListWidget().openPersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QMessageBox().open()
+ PySide2.QtWidgets.QPlainTextEdit.find(quintptr)
+ PySide2.QtWidgets.QProgressDialog().open()
+ PySide2.QtWidgets.QStackedLayout().widget()
+ # PySide2.QtWidgets.QStylePainter().begin(qPaintDevice) # QPaintDevice: NotImplementedError
+ PySide2.QtWidgets.QTableWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTableWidget().openPersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTextEdit.find(quintptr)
+ PySide2.QtWidgets.QTreeWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTreeWidget().openPersistentEditor(qModelIndex)
+ """
+except ImportError:
+ warn_essential(modname)
+try:
+ modname = "PySide2.QtPrintSupport"
+ exec("import " + modname)
+ new_functions += """
+ # PySide2.QtPrintSupport.QPageSetupDialog().open() # Segmentation fault: 11
+ # PySide2.QtPrintSupport.QPrintDialog().open() # opens the dialog, but works
+ PySide2.QtPrintSupport.QPrintDialog().printer()
+ PySide2.QtPrintSupport.QPrintPreviewDialog().open() # note: this prints something, but really shouldn't ;-)
+ """
+except ImportError:
+ warn_essential(modname)
+try:
import PySide2.QtHelp
new_functions += """
PySide2.QtHelp.QHelpContentModel().parent()
@@ -116,30 +139,43 @@ class MainTest(unittest.TestCase):
"""
Run all new method signarures
"""
- qApp = (PySide2.QtWidgets.QApplication.instance() or
- PySide2.QtWidgets.QApplication([]))
- openMode = PySide2.QtCore.QIODevice.OpenMode(PySide2.QtCore.QIODevice.ReadOnly)
+ for app in "QtWidgets.QApplication", "QtGui.QGuiApplication", "QtCore.QCoreApplication":
+ try:
+ exec("qApp = PySide2.{0}([]) or PySide2.{0}.instance()".format(app))
+ break
+ except AttributeError:
+ continue
+ bool = True
+ int = 42
qint64 = 42
+ tfarg = os.path.join(PySide2.QtCore.QDir.tempPath(), "XXXXXX.tmp")
+ orientation = PySide2.QtCore.Qt.Orientation()
+ openMode = PySide2.QtCore.QIODevice.OpenMode(PySide2.QtCore.QIODevice.ReadOnly)
qModelIndex = PySide2.QtCore.QModelIndex()
- qMatrix = PySide2.QtGui.QMatrix()
transformationMode = PySide2.QtCore.Qt.TransformationMode()
- qTextDocument = PySide2.QtGui.QTextDocument()
- qTextFormat = PySide2.QtGui.QTextFormat()
- int = 42
- quintptr = long(42) if sys.version_info[0] < 3 else 42
- qFont = PySide2.QtGui.QFont()
- qPalette = PySide2.QtGui.QPalette()
- direction = PySide2.QtWidgets.QBoxLayout.Direction()
- qWidget = PySide2.QtWidgets.QWidget()
- orientation = PySide2.QtCore.Qt.Orientation()
- qStyleOptionFrame = PySide2.QtWidgets.QStyleOptionFrame()
- bool = True
qObject = PySide2.QtCore.QObject()
- qAction = PySide2.QtWidgets.QAction(qObject)
- #qPaintDevice = PySide2.QtGui.QPaintDevice() # NotImplementedError
qPoint = PySide2.QtCore.QPoint()
- renderFlags = PySide2.QtWidgets.QWidget.RenderFlags
- tfarg = os.path.join(PySide2.QtCore.QDir.tempPath(), "XXXXXX.tmp")
+ try:
+ PySide2.QtGui
+ #qPaintDevice = PySide2.QtGui.QPaintDevice() # NotImplementedError
+ qMatrix = PySide2.QtGui.QMatrix()
+ qTextDocument = PySide2.QtGui.QTextDocument()
+ qTextFormat = PySide2.QtGui.QTextFormat()
+ quintptr = long(42) if sys.version_info[0] < 3 else 42
+ qFont = PySide2.QtGui.QFont()
+ qPalette = PySide2.QtGui.QPalette()
+ except AttributeError:
+ pass
+ try:
+ PySide2.QtWidgets
+ direction = PySide2.QtWidgets.QBoxLayout.Direction()
+ qWidget = PySide2.QtWidgets.QWidget()
+ qStyleOptionFrame = PySide2.QtWidgets.QStyleOptionFrame()
+ qAction = PySide2.QtWidgets.QAction(qObject)
+ renderFlags = PySide2.QtWidgets.QWidget.RenderFlags
+ except AttributeError:
+ pass
+
for func in new_functions.splitlines():
func = func.strip()
if func.startswith("#"):
@@ -158,8 +194,11 @@ class MainTest(unittest.TestCase):
Verify that qApp.palette owns three signatures, especially
palette() without argument.
"""
- qApp = (PySide2.QtWidgets.QApplication.instance() or
- PySide2.QtWidgets.QApplication([]))
+ try:
+ qApp = (PySide2.QtWidgets.QApplication.instance() or
+ PySide2.QtWidgets.QApplication([]))
+ except AttributeError:
+ unittest.TestCase().skipTest("this test makes only sense if QtWidgets is available.")
try:
PySide2.QtWidgets.QApplication.palette(42) # raises
except TypeError as e:
diff --git a/tests/pysidetest/typesystem_pysidetest.xml b/tests/pysidetest/typesystem_pysidetest.xml
index ea3a5bd8..4053b7b7 100644
--- a/tests/pysidetest/typesystem_pysidetest.xml
+++ b/tests/pysidetest/typesystem_pysidetest.xml
@@ -1,8 +1,6 @@
<?xml version="1.0"?>
<typesystem package="testbinding">
<load-typesystem name="typesystem_core.xml" generate="no" />
- <load-typesystem name="typesystem_gui.xml" generate="no"/>
- <load-typesystem name="typesystem_widgets.xml" generate="no"/>
<value-type name="IntValue"/>
<primitive-type name="TypedefValue">
<!--