aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r--sources/pyside6/tests/QtCore/qenum_test.py14
-rw-r--r--sources/pyside6/tests/QtCore/qflags_test.py20
-rw-r--r--sources/pyside6/tests/QtCore/qsysinfo_test.py10
-rw-r--r--sources/pyside6/tests/QtGui/bug_617.py9
-rw-r--r--sources/pyside6/tests/QtGui/qkeysequence_test.py19
-rw-r--r--sources/pyside6/tests/QtGui/qpen_test.py3
-rw-r--r--sources/pyside6/tests/QtSql/qvarianttype_test.py7
-rw-r--r--sources/pyside6/tests/QtWidgets/qformlayout_test.py65
-rw-r--r--sources/pyside6/tests/pysidetest/CMakeLists.txt1
-rw-r--r--sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py166
-rw-r--r--sources/pyside6/tests/pysidetest/qvariant_test.py17
-rw-r--r--sources/pyside6/tests/pysidetest/shared_pointer_test.py2
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp13
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.h4
-rw-r--r--sources/pyside6/tests/registry/existence_test.py17
-rw-r--r--sources/pyside6/tests/registry/init_platform.py60
16 files changed, 363 insertions, 64 deletions
diff --git a/sources/pyside6/tests/QtCore/qenum_test.py b/sources/pyside6/tests/QtCore/qenum_test.py
index 612a3873b..4514dd256 100644
--- a/sources/pyside6/tests/QtCore/qenum_test.py
+++ b/sources/pyside6/tests/QtCore/qenum_test.py
@@ -45,7 +45,7 @@ from PySide6.QtCore import Qt, QIODevice, QObject, QEnum, QFlag
class TestEnum(unittest.TestCase):
-
+ @unittest.skipIf(sys.pyside63_option_python_enum, "not adequate for new enums to ask the value")
def testToInt(self):
self.assertEqual(QIODevice.NotOpen, 0)
self.assertEqual(QIODevice.ReadOnly, 1)
@@ -56,6 +56,7 @@ class TestEnum(unittest.TestCase):
self.assertEqual(QIODevice.Text, 16)
self.assertEqual(QIODevice.Unbuffered, 32)
+ @unittest.skipIf(sys.pyside63_option_python_enum, "not adequate for new enums to ask the value")
def testToIntInFunction(self):
self.assertEqual(str(int(QIODevice.WriteOnly)), "2")
@@ -105,18 +106,21 @@ class TestEnum(unittest.TestCase):
class TestQFlags(unittest.TestCase):
+ newenum = sys.pyside63_option_python_enum
+
def testToItn(self):
om = QIODevice.NotOpen
+ omcmp = om.value if self.newenum else om
self.assertEqual(om, QIODevice.NotOpen)
- self.assertTrue(om == 0)
+ self.assertTrue(omcmp == 0)
- self.assertTrue(om != QIODevice.ReadOnly)
- self.assertTrue(om != 1)
+ self.assertTrue(omcmp != QIODevice.ReadOnly)
+ self.assertTrue(omcmp != 1)
def testToIntInFunction(self):
om = QIODevice.WriteOnly
- self.assertEqual(int(om), 2)
+ self.assertEqual(int(om.value if self.newenum else om), 2)
def testNonExtensibleEnums(self):
try:
diff --git a/sources/pyside6/tests/QtCore/qflags_test.py b/sources/pyside6/tests/QtCore/qflags_test.py
index 3800a003c..77e61560f 100644
--- a/sources/pyside6/tests/QtCore/qflags_test.py
+++ b/sources/pyside6/tests/QtCore/qflags_test.py
@@ -111,6 +111,25 @@ class QFlagOperatorTest(unittest.TestCase):
flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
self.assertEqual(flags | Qt.ItemIsEnabled, Qt.ItemIsEnabled | flags)
+ def testEqualNonNumericalObject(self):
+ '''QFlags ==,!= non-numerical object '''
+ flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+
+ self.assertTrue(flags != None) # noqa: E711
+ self.assertFalse(flags == None) # noqa: E711
+
+ self.assertTrue(flags != "tomato")
+ self.assertFalse(flags == "tomato")
+
+ with self.assertRaises(TypeError):
+ flags > None
+ with self.assertRaises(TypeError):
+ flags >= None
+ with self.assertRaises(TypeError):
+ flags < None
+ with self.assertRaises(TypeError):
+ flags <= None
+
class QFlagsOnQVariant(unittest.TestCase):
def testQFlagsOnQVariant(self):
@@ -120,6 +139,7 @@ class QFlagsOnQVariant(unittest.TestCase):
class QFlagsWrongType(unittest.TestCase):
+ @unittest.skipIf(sys.pyside63_option_python_enum, "Qt.ItemFlag is no longer an IntEnum")
def testWrongType(self):
'''Wrong type passed to QFlags binary operators'''
for op in operator.or_, operator.and_, operator.xor:
diff --git a/sources/pyside6/tests/QtCore/qsysinfo_test.py b/sources/pyside6/tests/QtCore/qsysinfo_test.py
index ebd0f82ee..b55d4380c 100644
--- a/sources/pyside6/tests/QtCore/qsysinfo_test.py
+++ b/sources/pyside6/tests/QtCore/qsysinfo_test.py
@@ -39,13 +39,15 @@ from PySide6.QtCore import QSysInfo
class TestQSysInfo(unittest.TestCase):
+ newenum = sys.pyside63_option_python_enum
+
def testEnumEndian(self):
- self.assertEqual(QSysInfo.BigEndian, 0)
- self.assertEqual(QSysInfo.LittleEndian, 1)
- self.assertTrue(QSysInfo.ByteOrder > -1)
+ self.assertEqual(QSysInfo.BigEndian.value if self.newenum else QSysInfo.BigEndian, 0)
+ self.assertEqual(QSysInfo.LittleEndian.value if self.newenum else QSysInfo.LittleEndian, 1)
+ self.assertTrue((QSysInfo.ByteOrder.value if self.newenum else QSysInfo.ByteOrder) > -1)
def testEnumSizes(self):
- self.assertTrue(QSysInfo.WordSize > 0)
+ self.assertTrue((QSysInfo.WordSize.value if self.newenum else QSysInfo.WordSize) > 0)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/bug_617.py b/sources/pyside6/tests/QtGui/bug_617.py
index 36ad2b8ed..b8e578d1b 100644
--- a/sources/pyside6/tests/QtGui/bug_617.py
+++ b/sources/pyside6/tests/QtGui/bug_617.py
@@ -41,12 +41,7 @@ from PySide6.QtGui import QColor
class MyEvent(QEvent):
def __init__(self):
- if sys.pyside63_option_python_enum:
- # PYSIDE-1735: Python Enum: We cannot assign arbitrary numbers.
- # They must exist as constants in the type.
- QEvent.__init__(self, QEvent.Type(1000))
- else:
- QEvent.__init__(self, QEvent.Type(999))
+ QEvent.__init__(self, QEvent.Type(999))
class Bug617(unittest.TestCase):
@@ -57,7 +52,7 @@ class Bug617(unittest.TestCase):
def testOutOfBounds(self):
e = MyEvent()
- self.assertEqual(repr(e.type()), "<Type.User: 1000>"
+ self.assertEqual(repr(e.type()), "<Type.999: 999>"
if sys.pyside63_option_python_enum else "PySide6.QtCore.QEvent.Type(999)")
diff --git a/sources/pyside6/tests/QtGui/qkeysequence_test.py b/sources/pyside6/tests/QtGui/qkeysequence_test.py
index 4ec261a9f..112c22b9a 100644
--- a/sources/pyside6/tests/QtGui/qkeysequence_test.py
+++ b/sources/pyside6/tests/QtGui/qkeysequence_test.py
@@ -45,11 +45,20 @@ class QKeySequenceTest(UsesQGuiApplication):
def testGetItemOperator(self):
# bug #774
- ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
- self.assertEqual(ks[0], Qt.SHIFT)
- self.assertEqual(ks[1], Qt.CTRL)
- self.assertEqual(ks[2], Qt.Key_P)
- self.assertEqual(ks[3], Qt.Key_R)
+ if sys.pyside63_option_python_enum:
+ # PYSIDE-1735: Remapped from Qt.Modifier to Qt.KeyboardModifier
+ # Note that Qt.(Keyboard)?Modifier will be no longer IntFlag.
+ ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R)
+ self.assertEqual(ks[0].keyboardModifiers(), Qt.ShiftModifier)
+ self.assertEqual(ks[1].keyboardModifiers(), Qt.ControlModifier)
+ self.assertEqual(ks[2].key(), Qt.Key_P)
+ self.assertEqual(ks[3].key(), Qt.Key_R)
+ else:
+ ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
+ self.assertEqual(ks[0], Qt.SHIFT)
+ self.assertEqual(ks[1], Qt.CTRL)
+ self.assertEqual(ks[2], Qt.Key_P)
+ self.assertEqual(ks[3], Qt.Key_R)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/qpen_test.py b/sources/pyside6/tests/QtGui/qpen_test.py
index a1148b4fa..3c1ae9f6b 100644
--- a/sources/pyside6/tests/QtGui/qpen_test.py
+++ b/sources/pyside6/tests/QtGui/qpen_test.py
@@ -51,7 +51,8 @@ class Painting(QRasterWindow):
with QPainter(self) as painter:
painter.setPen(Qt.NoPen)
self.penFromEnum = painter.pen()
- painter.setPen(int(Qt.NoPen))
+ intVal = Qt.NoPen.value if sys.pyside63_option_python_enum else int(Qt.NoPen)
+ painter.setPen(intVal)
self.penFromInteger = painter.pen()
QTimer.singleShot(20, self.close)
diff --git a/sources/pyside6/tests/QtSql/qvarianttype_test.py b/sources/pyside6/tests/QtSql/qvarianttype_test.py
index 2b3dfa4b0..c62c7a55f 100644
--- a/sources/pyside6/tests/QtSql/qvarianttype_test.py
+++ b/sources/pyside6/tests/QtSql/qvarianttype_test.py
@@ -42,11 +42,14 @@ from PySide6.QtSql import QSqlField
class QVariantTypeTest(unittest.TestCase):
def testQVariantType(self):
+ new_enum = sys.pyside63_option_python_enum
+ cmp_id = QMetaType.QString.value if new_enum else QMetaType.QString
+
f = QSqlField("name", QMetaType(QMetaType.QString))
- self.assertEqual(f.metaType().id(), QMetaType.QString)
+ self.assertEqual(f.metaType().id(), cmp_id)
f = QSqlField("name", QMetaType.fromName(b"QString"))
- self.assertEqual(f.metaType().id(), QMetaType.QString)
+ self.assertEqual(f.metaType().id(), cmp_id)
f = QSqlField("name", QMetaType.fromName(b"double"))
self.assertEqual(f.metaType(), float)
diff --git a/sources/pyside6/tests/QtWidgets/qformlayout_test.py b/sources/pyside6/tests/QtWidgets/qformlayout_test.py
index 55348daaa..7cd59b63f 100644
--- a/sources/pyside6/tests/QtWidgets/qformlayout_test.py
+++ b/sources/pyside6/tests/QtWidgets/qformlayout_test.py
@@ -35,7 +35,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6.QtWidgets import QFormLayout, QWidget
+from PySide6.QtWidgets import QFormLayout, QWidget, QLabel, QMainWindow
from helper.usesqapplication import UsesQApplication
@@ -44,12 +44,11 @@ class QFormLayoutTest(UsesQApplication):
def testGetItemPosition(self):
formlayout = QFormLayout()
- if not sys.pyside63_option_python_enum:
- # PYSIDE-1735: This gives random values if no row exists.
- row, role = formlayout.getItemPosition(0)
- self.assertTrue(isinstance(row, int))
- self.assertTrue(isinstance(role, QFormLayout.ItemRole))
- self.assertEqual(row, -1)
+
+ row, role = formlayout.getItemPosition(0)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
widget = QWidget()
formlayout.addRow(widget)
@@ -62,12 +61,11 @@ class QFormLayoutTest(UsesQApplication):
def testGetWidgetPosition(self):
formlayout = QFormLayout()
widget = QWidget()
- if not sys.pyside63_option_python_enum:
- # PYSIDE-1735: This gives random values if no row exists.
- row, role = formlayout.getWidgetPosition(widget)
- self.assertTrue(isinstance(row, int))
- self.assertTrue(isinstance(role, QFormLayout.ItemRole))
- self.assertEqual(row, -1)
+
+ row, role = formlayout.getWidgetPosition(widget)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
formlayout.addRow(widget)
row, role = formlayout.getWidgetPosition(widget)
@@ -79,12 +77,11 @@ class QFormLayoutTest(UsesQApplication):
def testGetLayoutPosition(self):
formlayout = QFormLayout()
layout = QFormLayout()
- if not sys.pyside63_option_python_enum:
- # PYSIDE-1735: This gives random values if no row exists.
- row, role = formlayout.getLayoutPosition(layout)
- self.assertTrue(isinstance(row, int))
- self.assertTrue(isinstance(role, QFormLayout.ItemRole))
- self.assertEqual(row, -1)
+
+ row, role = formlayout.getLayoutPosition(layout)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
formlayout.addRow(layout)
row, role = formlayout.getLayoutPosition(layout)
@@ -93,7 +90,35 @@ class QFormLayoutTest(UsesQApplication):
self.assertEqual(row, 0)
self.assertEqual(role, QFormLayout.SpanningRole)
+ def testTakeRow(self):
+ window = QMainWindow()
+ window.setCentralWidget(QWidget())
+ formlayout = QFormLayout(window.centralWidget())
+
+ widget_label = "blub"
+ widget = QLabel(widget_label)
+
+ self.assertEqual(formlayout.count(), 0)
+ formlayout.addRow(widget)
+ self.assertEqual(formlayout.count(), 1)
+ self.assertEqual(formlayout.itemAt(0).widget(), widget)
+
+ widget_id = id(widget)
+
+ # Now there are no more references to the original widget on the
+ # Python side. Assert that this does not break the references to
+ # the widget on the C++ side so that "taking" the row will work.
+ del widget
+
+ takeRowResult = formlayout.takeRow(0)
+ self.assertEqual(formlayout.count(), 0)
+
+ widget = takeRowResult.fieldItem.widget()
+
+ self.assertIsNotNone(widget)
+ self.assertEqual(widget_id, id(widget))
+ self.assertEqual(widget.text(), widget_label)
+
if __name__ == "__main__":
unittest.main()
-
diff --git a/sources/pyside6/tests/pysidetest/CMakeLists.txt b/sources/pyside6/tests/pysidetest/CMakeLists.txt
index ee2a295fe..f7df67751 100644
--- a/sources/pyside6/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside6/tests/pysidetest/CMakeLists.txt
@@ -157,3 +157,4 @@ PYSIDE_TEST(signalwithdefaultvalue_test.py)
PYSIDE_TEST(typedef_signal_test.py)
PYSIDE_TEST(version_test.py)
PYSIDE_TEST(mock_as_slot_test.py)
+PYSIDE_TEST(pyenum_relax_options_test.py)
diff --git a/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py b/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py
new file mode 100644
index 000000000..844fc2bce
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py
@@ -0,0 +1,166 @@
+#!/usr/bin/python
+#############################################################################
+##
+## Copyright (C) 2022 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""
+PYSIDE-1735: Testing different relax options for Enums
+
+This test uses different configurations and initializes QtCore with it.
+Because re-initialization is not possible, the test uses a subprocess
+for it. This makes the test pretty slow.
+
+Maybe we should implement a way to re-initialize QtCore enums without
+using subprocess, just to speed this up??
+"""
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+import subprocess
+import tempfile
+from textwrap import dedent
+
+
+def runtest(program):
+ passed_path = os.fspath(Path(__file__).resolve().parents[1])
+ with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".py") as fp:
+ preamble = dedent(f"""
+ import os
+ import sys
+ from pathlib import Path
+ sys.path.append({passed_path!r})
+ from init_paths import init_test_paths
+ init_test_paths(False)
+ """)
+ print(preamble, program, file=fp)
+ fp.close()
+ try:
+ subprocess.run([sys.executable, fp.name], check=True, capture_output=True)
+ return True
+ except subprocess.CalledProcessError as e:
+ print(f"\ninfo: {e.__class__.__name__}: {e.stderr}")
+ return False
+ finally:
+ os.unlink(fp.name)
+
+def testprog2(option):
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ from enum import IntEnum
+ assert(issubclass(QtCore.Qt.DateFormat, IntEnum))
+ """))
+
+def testprog4(option):
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.QtDebugMsg
+ """))
+
+def testprog8_16(option):
+ # this test needs flag 16, or the effect would be hidden by forgiving mode
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.AlignTop
+ """))
+
+def testprog32(option):
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.Alignment
+ """))
+
+def testprog64(option):
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.AlignmentFlag()
+ """))
+
+def testprog128(option):
+ return runtest(dedent(f"""
+ sys.pyside63_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.Key(1234567)
+ """))
+
+
+class TestPyEnumRelaxOption(unittest.TestCase):
+ """
+ This test is a bit involved, because we cannot unload QtCore after it is loaded once.
+ We use subprocess to test different cases, anyway.
+ """
+
+ def test_enumIsIntEnum(self):
+ self.assertTrue(testprog2(2))
+ self.assertFalse(testprog2(4))
+
+ def test_globalDefault(self):
+ self.assertTrue(testprog4(4))
+ self.assertFalse(testprog4(1))
+ self.assertTrue(testprog4(12))
+
+ def test_localDefault(self):
+ self.assertTrue(testprog8_16(8+16))
+ self.assertFalse(testprog8_16(0+16))
+
+ def test_fakeRenames(self):
+ self.assertTrue(testprog32(1))
+ self.assertFalse(testprog32(32))
+
+ def test_zeroDefault(self):
+ self.assertTrue(testprog64(1))
+ self.assertFalse(testprog64(64))
+
+ def test_Missing(self):
+ self.assertTrue(testprog128(1))
+ self.assertFalse(testprog128(128))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/qvariant_test.py b/sources/pyside6/tests/pysidetest/qvariant_test.py
index 637aa95cf..e6977082e 100644
--- a/sources/pyside6/tests/pysidetest/qvariant_test.py
+++ b/sources/pyside6/tests/pysidetest/qvariant_test.py
@@ -36,8 +36,8 @@ from init_paths import init_test_paths
init_test_paths(True)
from testbinding import TestObject
-from PySide6.QtCore import Qt
-from PySide6.QtGui import QKeySequence
+from PySide6.QtCore import Qt, QKeyCombination
+from PySide6.QtGui import QKeySequence, QAction
from helper.usesqapplication import UsesQApplication
@@ -46,9 +46,20 @@ class QVariantTest(UsesQApplication):
def testQKeySequenceQVariantOperator(self):
# bug #775
- ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
+ ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R)
self.assertEqual(TestObject.checkType(ks), 4107)
+ # PYSIDE-1735: Test the new way to address QKeyCombination after moving IntEnum to Enum
+ @unittest.skipUnless(sys.pyside63_option_python_enum, "only implemented for new enums")
+ def testQKeySequenceMoreVariations(self):
+ QAction().setShortcut(Qt.CTRL | Qt.Key_B)
+ QAction().setShortcut(Qt.CTRL | Qt.ALT | Qt.Key_B)
+ QAction().setShortcut(Qt.CTRL | Qt.AltModifier | Qt.Key_B)
+ QAction().setShortcut(QKeySequence(QKeyCombination(Qt.CTRL | Qt.Key_B)))
+ QKeySequence(Qt.CTRL | Qt.Key_Q)
+ # Issues a warning but works as well
+ QKeySequence(Qt.CTRL + Qt.Key_Q)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/shared_pointer_test.py b/sources/pyside6/tests/pysidetest/shared_pointer_test.py
index e5baa551c..c0b875407 100644
--- a/sources/pyside6/tests/pysidetest/shared_pointer_test.py
+++ b/sources/pyside6/tests/pysidetest/shared_pointer_test.py
@@ -45,6 +45,8 @@ class SharedPointerTests(unittest.TestCase):
p = SharedPointerTestbench.createSharedPointerQObject()
self.assertEqual(p.objectName(), "TestObject")
SharedPointerTestbench.printSharedPointerQObject(p)
+ p = SharedPointerTestbench.createSharedPointerConstQObject()
+ SharedPointerTestbench.printSharedPointerConstQObject(p)
def testIntSharedPointer(self):
p = SharedPointerTestbench.createSharedPointerInt(42)
diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
index f04059043..46875345b 100644
--- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
@@ -54,3 +54,16 @@ void SharedPointerTestbench::printSharedPointerQObject(const QSharedPointer<QObj
{
qDebug() << __FUNCTION__ << p.data();
}
+
+QSharedPointer<const QObject> SharedPointerTestbench::createSharedPointerConstQObject()
+{
+ auto *o = new QObject;
+ o->setObjectName(u"ConstTestObject"_qs);
+ QSharedPointer<const QObject> result(o);
+ return result;
+}
+
+void SharedPointerTestbench::printSharedPointerConstQObject(const QSharedPointer<const QObject> &p)
+{
+ qDebug() << __FUNCTION__ << p.data();
+}
diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
index 1732a59e5..7abbf6d29 100644
--- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
@@ -45,6 +45,10 @@ public:
static QSharedPointer<QObject> createSharedPointerQObject();
static void printSharedPointerQObject(const QSharedPointer<QObject> &p);
+
+ static QSharedPointer<const QObject> createSharedPointerConstQObject();
+ static void printSharedPointerConstQObject(const QSharedPointer<const QObject> &p);
+
};
#endif // SHAREDPOINTERTESTBENCH_H
diff --git a/sources/pyside6/tests/registry/existence_test.py b/sources/pyside6/tests/registry/existence_test.py
index 2ab18152a..fa6cdde34 100644
--- a/sources/pyside6/tests/registry/existence_test.py
+++ b/sources/pyside6/tests/registry/existence_test.py
@@ -72,8 +72,8 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_all_test_paths
-init_all_test_paths()
+from init_paths import init_test_paths
+init_test_paths(True)
from init_platform import enum_all, generate_all
from util import (isolate_warnings, check_warnings, suppress_warnings, warn,
@@ -119,6 +119,19 @@ if have_refmodule and not hasattr(sig_exists, dict_name):
have_refmodule = False
+class TestUnrecognizedOffending(unittest.TestCase):
+ """
+ We run the signature generation on all modules and raise an error
+ if a warning was issued. This is better than turning warnings into
+ errors because that would stop early before we have all warnings.
+ """
+ def test_signatures_recognized(self):
+ with isolate_warnings():
+ found_sigs = enum_all()
+ if check_warnings():
+ raise RuntimeError("There are errors, see above.")
+
+
@unittest.skipIf(not have_refmodule,
"not activated for this platform or version")
class TestSignaturesExists(unittest.TestCase):
diff --git a/sources/pyside6/tests/registry/init_platform.py b/sources/pyside6/tests/registry/init_platform.py
index 06c488ee3..e22d2c9b8 100644
--- a/sources/pyside6/tests/registry/init_platform.py
+++ b/sources/pyside6/tests/registry/init_platform.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2019 The Qt Company Ltd.
+## Copyright (C) 2022 The Qt Company Ltd.
## Contact: https://www.qt.io/licensing/
##
## This file is part of Qt for Python.
@@ -113,13 +113,7 @@ def set_ospaths(build_dir):
ps = os.pathsep
ospath_var = "PATH" if sys.platform == "win32" else "LD_LIBRARY_PATH"
old_val = os.environ.get(ospath_var, "")
- lib_path = [os.path.join(build_dir, "pyside6", "libpyside"),
- os.path.join(build_dir, "pyside6", "tests", "pysidetest"),
- os.path.join(build_dir, "shiboken6", "tests", "libminimal"),
- os.path.join(build_dir, "shiboken6", "tests", "libsample"),
- os.path.join(build_dir, "shiboken6", "tests", "libother"),
- os.path.join(build_dir, "shiboken6", "tests", "libsmart"),
- os.path.join(build_dir, "shiboken6", "libshiboken")]
+ lib_path = [os.path.join(build_dir, "pyside6", "tests", "pysidetest"),]
ospath = ps.join(lib_path + old_val.split(ps))
os.environ[ospath_var] = ospath
@@ -139,12 +133,6 @@ all_modules.append("testbinding")
from shiboken6 import Shiboken
all_modules.append("shiboken6.Shiboken")
-# 'sample/smart' are needed by 'other', so import them first.
-for modname in "minimal sample smart other".split():
- sys.path.insert(0, os.path.join(shiboken_build_dir, "tests", modname + "binding"))
- __import__(modname)
- all_modules.append(modname)
-
from shibokensupport.signature.lib.enum_sig import SimplifyingEnumerator
# Make sure not to get .pyc in Python2.
@@ -208,6 +196,48 @@ def enum_all():
return ret
+LICENSE_TEXT = """
+#############################################################################
+##
+## Copyright (C) 2022 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+"""
+
+
def generate_all():
refPath = get_refpath()
module = os.path.basename(os.path.splitext(refPath)[0])
@@ -218,7 +248,7 @@ def generate_all():
license_line = next((lno for lno, line in enumerate(lines)
if "$QT_END_LICENSE$" in line))
fmt.print("#recreate # uncomment this to enforce generation")
- fmt.print("".join(lines[:license_line + 3]))
+ fmt.print(LICENSE_TEXT)
version = sys.version.replace('\n', ' ')
build = qt_build()
fmt.print(dedent(f'''\