diff options
Diffstat (limited to 'sources/pyside6/tests/QtCore')
151 files changed, 2063 insertions, 4143 deletions
diff --git a/sources/pyside6/tests/QtCore/CMakeLists.txt b/sources/pyside6/tests/QtCore/CMakeLists.txt index 82585f89c..f584bfde6 100644 --- a/sources/pyside6/tests/QtCore/CMakeLists.txt +++ b/sources/pyside6/tests/QtCore/CMakeLists.txt @@ -1,5 +1,10 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + PYSIDE_TEST(attr_cache_py3k.py) PYSIDE_TEST(bug_278_test.py) +PYSIDE_TEST(bug_300_test.py) +PYSIDE_TEST(bug_324.py) PYSIDE_TEST(bug_332.py) PYSIDE_TEST(bug_408.py) PYSIDE_TEST(bug_428.py) @@ -26,6 +31,7 @@ PYSIDE_TEST(bug_1019.py) PYSIDE_TEST(bug_1063.py) PYSIDE_TEST(bug_1069.py) PYSIDE_TEST(bug_1313.py) +PYSIDE_TEST(bug_PYSIDE-41.py) PYSIDE_TEST(bug_PYSIDE-42.py) PYSIDE_TEST(bug_PYSIDE-164.py) PYSIDE_TEST(blocking_signals_test.py) @@ -37,6 +43,7 @@ PYSIDE_TEST(destroysignal_test.py) PYSIDE_TEST(duck_punching_test.py) PYSIDE_TEST(emoji_string_test.py) PYSIDE_TEST(errormessages_with_features_test.py) +PYSIDE_TEST(feature_with_uic_test.py) PYSIDE_TEST(hash_test.py) PYSIDE_TEST(inherits_test.py) PYSIDE_TEST(max_signals.py) @@ -77,6 +84,7 @@ PYSIDE_TEST(qlocale_test.py) PYSIDE_TEST(qlockfile_test.py) PYSIDE_TEST(qmessageauthenticationcode_test.py) PYSIDE_TEST(qmetaobject_test.py) +PYSIDE_TEST(qmetatype_test.py) PYSIDE_TEST(qmimedatabase_test.py) PYSIDE_TEST(qmodelindex_internalpointer_test.py) PYSIDE_TEST(qobject_children_segfault_test.py) @@ -121,6 +129,7 @@ PYSIDE_TEST(quuid_test.py) PYSIDE_TEST(qversionnumber_test.py) PYSIDE_TEST(repr_test.py) PYSIDE_TEST(setprop_on_ctor_test.py) +PYSIDE_TEST(signal_sender.py) PYSIDE_TEST(snake_prop_feature_test.py) PYSIDE_TEST(staticMetaObject_test.py) PYSIDE_TEST(static_method_test.py) @@ -130,6 +139,8 @@ PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) PYSIDE_TEST(versioninfo_test.py) +PYSIDE_TEST(loggingcategorymacros_test.py) +PYSIDE_TEST(qrunnable_test.py) if(X11) PYSIDE_TEST(qhandle_test.py) diff --git a/sources/pyside6/tests/QtCore/QtCore.pyproject b/sources/pyside6/tests/QtCore/QtCore.pyproject new file mode 100644 index 000000000..bd5951316 --- /dev/null +++ b/sources/pyside6/tests/QtCore/QtCore.pyproject @@ -0,0 +1,148 @@ +{ + "files": ["attr_cache_py3k.py", + "blocking_signals_test.py", + "bug_1019.py", + "bug_1063.py", + "bug_1069.py", + "bug_1313.py", + "bug_278_test.py", + "bug_300_test.py", + "bug_324.py", + "bug_332.py", + "bug_408.py", + "bug_428.py", + "bug_462.py", + "bug_505.py", + "bug_515.py", + "bug_606.py", + "bug_656.py", + "bug_686.py", + "bug_699.py", + "bug_706.py", + "bug_820.py", + "bug_826.py", + "bug_829.py", + "bug_835.py", + "bug_920.py", + "bug_927.py", + "bug_931.py", + "bug_938.py", + "bug_953.py", + "bug_987.py", + "bug_994.py", + "bug_PYSIDE-164.py", + "bug_PYSIDE-41.py", + "bug_PYSIDE-42.py", + "child_event_test.py", + "classinfo_test.py", + "deepcopy_test.py", + "deletelater_test.py", + "destroysignal_test.py", + "duck_punching_test.py", + "emoji_string_test.py", + "errormessages_with_features_test.py", + "feature_with_uic/window.py", + "feature_with_uic/window.ui", + "feature_with_uic_test.py", + "hash_test.py", + "inherits_test.py", + "loggingcategorymacros_test.py", + "max_signals.py", + "missing_symbols_test.py", + "mockclass_test.py", + "multiple_feature_test.py", + "python_conversion.py", + "qabs_test.py", + "qabstractitemmodel_test.py", + "qanimationgroup_test.py", + "qbitarray_test.py", + "qbytearray_concatenation_operator_test.py", + "qbytearray_operator_iadd_test.py", + "qbytearray_operator_test.py", + "qbytearray_test.py", + "qcalendar_test.py", + "qcbor_test.py", + "qcollator_test.py", + "qcommandlineparser_test.py", + "qcoreapplication_argv_test.py", + "qcoreapplication_instance_test.py", + "qcoreapplication_test.py", + "qdatastream_test.py", + "qdate_test.py", + "qdatetime_test.py", + "qdir_test.py", + "qeasingcurve_test.py", + "qenum_test.py", + "qevent_test.py", + "qfile_test.py", + "qfileinfo_test.py", + "qfileread_test.py", + "qflags_test.py", + "qhandle_test.py", + "qinstallmsghandler_test.py", + "qjsondocument_test.py", + "qlinef_test.py", + "qlocale_test.py", + "qlockfile_test.py", + "qmessageauthenticationcode_test.py", + "qmetaobject_test.py", + "qmetatype_test.py", + "qmimedatabase_test.py", + "qmodelindex_internalpointer_test.py", + "qobject_children_segfault_test.py", + "qobject_connect_notify_test.py", + "qobject_destructor.py", + "qobject_event_filter_test.py", + "qobject_inherits_test.py", + "qobject_objectproperty_test.py", + "qobject_parent_test.py", + "qobject_property_test.py", + "qobject_protected_methods_test.py", + "qobject_test.py", + "qobject_timer_event_test.py", + "qobject_tr_as_instance_test.py", + "qoperatingsystemversion_test.py", + "qpoint_test.py", + "qprocess_test.py", + "qproperty_decorator.py", + "qrandomgenerator_test.py", + "qrect_test.py", + "qregularexpression_test.py", + "qresource_test.py", + "qsettings_test.py", + "qsharedmemory_client.py", + "qsharedmemory_test.py", + "qsize_test.py", + "qslot_object_test.py", + "qsocketnotifier_test.py", + "qsrand_test.py", + "qstandardpaths_test.py", + "qstorageinfo_test.py", + "qstring_test.py", + "qsysinfo_test.py", + "qtextstream_test.py", + "qthread_prod_cons_test.py", + "qthread_signal_test.py", + "qthread_test.py", + "qtimer_singleshot_test.py", + "qtimer_timeout_test.py", + "qtimezone_test.py", + "qtnamespace_test.py", + "qurl_test.py", + "qurlquery_test.py", + "quuid_test.py", + "qversionnumber_test.py", + "repr_test.py", + "resources.qrc", + "resources_mc.py", + "setprop_on_ctor_test.py", + "snake_prop_feature_test.py", + "staticMetaObject_test.py", + "static_method_test.py", + "thread_signals_test.py", + "tr_noop_test.py", + "translation_test.py", + "unaryoperator_test.py", + "unicode_test.py", + "versioninfo_test.py"] +} diff --git a/sources/pyside6/tests/QtCore/attr_cache_py3k.py b/sources/pyside6/tests/QtCore/attr_cache_py3k.py index 4044b5f64..c82dbbea3 100644 --- a/sources/pyside6/tests/QtCore/attr_cache_py3k.py +++ b/sources/pyside6/tests/QtCore/attr_cache_py3k.py @@ -1,43 +1,5 @@ -# This Python file uses the following encoding: utf-8 - -############################################################################# -## -## Copyright (C) 2018 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$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only ''' Unit tests for attribute cache in Python 3 diff --git a/sources/pyside6/tests/QtCore/blocking_signals_test.py b/sources/pyside6/tests/QtCore/blocking_signals_test.py index b51ba2c7a..493abb071 100644 --- a/sources/pyside6/tests/QtCore/blocking_signals_test.py +++ b/sources/pyside6/tests/QtCore/blocking_signals_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' Test case for QObject.signalsBlocked() and blockSignal()''' +import gc import os import sys from tempfile import mkstemp @@ -38,7 +14,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QObject, SIGNAL, QFile, QSignalBlocker +from PySide6.QtCore import QObject, Signal, QFile, QSignalBlocker + + +class Sender(QObject): + mysignal = Signal() + mysignal_int_int = Signal(int, int) class TestSignalsBlockedBasic(unittest.TestCase): @@ -60,6 +41,8 @@ class TestSignalsBlockedBasic(unittest.TestCase): blocker.reblock() self.assertTrue(obj.signalsBlocked()) del blocker + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertTrue(not obj.signalsBlocked()) def testContext(self): @@ -69,13 +52,21 @@ class TestSignalsBlockedBasic(unittest.TestCase): self.assertTrue(obj.signalsBlocked()) self.assertTrue(not obj.signalsBlocked()) + def testContextWithAs(self): + obj = QObject() + self.assertTrue(not obj.signalsBlocked()) + with QSignalBlocker(obj) as blocker: + self.assertTrue(obj.signalsBlocked()) + self.assertEqual(type(blocker), QSignalBlocker) + self.assertTrue(not obj.signalsBlocked()) + class TestSignalsBlocked(unittest.TestCase): '''Test case to check if the signals are really blocked''' def setUp(self): # Set up the basic resources needed - self.obj = QObject() + self.obj = Sender() self.args = tuple() self.called = False @@ -83,6 +74,8 @@ class TestSignalsBlocked(unittest.TestCase): # Delete used resources del self.obj del self.args + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def callback(self, *args): # Default callback @@ -93,27 +86,28 @@ class TestSignalsBlocked(unittest.TestCase): def testShortCircuitSignals(self): # Blocking of Python short-circuit signals - QObject.connect(self.obj, SIGNAL('mysignal()'), self.callback) + self.obj.mysignal.connect(self.callback) - self.obj.emit(SIGNAL('mysignal()')) + self.obj.mysignal.emit() self.assertTrue(self.called) self.called = False self.obj.blockSignals(True) - self.obj.emit(SIGNAL('mysignal()')) + self.obj.mysignal.emit() self.assertTrue(not self.called) def testPythonSignals(self): # Blocking of Python typed signals - QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback) + + self.obj.mysignal_int_int.connect(self.callback) self.args = (1, 3) - self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) + self.obj.mysignal_int_int.emit(*self.args) self.assertTrue(self.called) self.called = False self.obj.blockSignals(True) - self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) + self.obj.mysignal_int_int.emit(*self.args) self.assertTrue(not self.called) @@ -132,6 +126,8 @@ class TestQFileSignalBlocking(unittest.TestCase): # Release acquired resources os.remove(self.filename) del self.qfile + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def callback(self): # Default callback @@ -140,7 +136,7 @@ class TestQFileSignalBlocking(unittest.TestCase): def testAboutToCloseBlocking(self): # QIODevice.aboutToClose() blocking - QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback) + self.qfile.aboutToClose.connect(self.callback) self.assertTrue(self.qfile.open(QFile.ReadOnly)) self.qfile.close() diff --git a/sources/pyside6/tests/QtCore/bug_1019.py b/sources/pyside6/tests/QtCore/bug_1019.py index 125951452..4a35956b1 100644 --- a/sources/pyside6/tests/QtCore/bug_1019.py +++ b/sources/pyside6/tests/QtCore/bug_1019.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -55,6 +30,7 @@ class MyTimer2 (MyTimer): pass def start(self): + """ 'Overrides' non-virtual slot QTimer.start().""" self.startCalled = True QCoreApplication.instance().quit() diff --git a/sources/pyside6/tests/QtCore/bug_1063.py b/sources/pyside6/tests/QtCore/bug_1063.py index e83886221..88c4bb51e 100644 --- a/sources/pyside6/tests/QtCore/bug_1063.py +++ b/sources/pyside6/tests/QtCore/bug_1063.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' unit test for BUG #1063 ''' diff --git a/sources/pyside6/tests/QtCore/bug_1069.py b/sources/pyside6/tests/QtCore/bug_1069.py index ca99a408d..760918cd9 100644 --- a/sources/pyside6/tests/QtCore/bug_1069.py +++ b/sources/pyside6/tests/QtCore/bug_1069.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' unit test for BUG #1069 ''' diff --git a/sources/pyside6/tests/QtCore/bug_1313.py b/sources/pyside6/tests/QtCore/bug_1313.py index d384b44ba..ecc22c43b 100644 --- a/sources/pyside6/tests/QtCore/bug_1313.py +++ b/sources/pyside6/tests/QtCore/bug_1313.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2020 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' unit test for BUG #1313 ''' diff --git a/sources/pyside6/tests/QtCore/bug_278_test.py b/sources/pyside6/tests/QtCore/bug_278_test.py index b130d2b03..8d2f4b47e 100644 --- a/sources/pyside6/tests/QtCore/bug_278_test.py +++ b/sources/pyside6/tests/QtCore/bug_278_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_300_test.py b/sources/pyside6/tests/QtCore/bug_300_test.py new file mode 100644 index 000000000..b9768bf9d --- /dev/null +++ b/sources/pyside6/tests/QtCore/bug_300_test.py @@ -0,0 +1,29 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +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) + +from PySide6.QtCore import QModelIndex, QStringListModel + + +class TestQAbstractItemModelSignals(unittest.TestCase): + def sigCallback(self, index, r, c): + self._called = True + + def testSignals(self): + self._called = False + m = QStringListModel() + m.rowsAboutToBeInserted[QModelIndex, int, int].connect(self.sigCallback) + m.insertRows(0, 3) + self.assertTrue(self._called) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_324.py b/sources/pyside6/tests/QtCore/bug_324.py new file mode 100644 index 000000000..0aa17c465 --- /dev/null +++ b/sources/pyside6/tests/QtCore/bug_324.py @@ -0,0 +1,43 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +''' Test bug 324: http://bugs.openbossa.org/show_bug.cgi?id=324''' + +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) + +from PySide6.QtCore import QCoreApplication, QObject, Signal + + +class QBug(QObject): + def __init__(self, parent=None): + QObject.__init__(self, parent) + + def check(self): + self.done.emit("abc") + + done = Signal(str) + + +class Bug324(unittest.TestCase): + + def on_done(self, val): + self.value = val + + def testBug(self): + app = QCoreApplication([]) + bug = QBug() + self.value = '' + bug.done.connect(self.on_done) + bug.check() + self.assertEqual(self.value, 'abc') + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_332.py b/sources/pyside6/tests/QtCore/bug_332.py index 333f7fcdf..8d55bc87f 100644 --- a/sources/pyside6/tests/QtCore/bug_332.py +++ b/sources/pyside6/tests/QtCore/bug_332.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_408.py b/sources/pyside6/tests/QtCore/bug_408.py index cb501bcfb..30459172c 100644 --- a/sources/pyside6/tests/QtCore/bug_408.py +++ b/sources/pyside6/tests/QtCore/bug_408.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_428.py b/sources/pyside6/tests/QtCore/bug_428.py index 184f7a30d..8fb5d4827 100644 --- a/sources/pyside6/tests/QtCore/bug_428.py +++ b/sources/pyside6/tests/QtCore/bug_428.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_462.py b/sources/pyside6/tests/QtCore/bug_462.py index 1d16e2ab9..04a42fe08 100644 --- a/sources/pyside6/tests/QtCore/bug_462.py +++ b/sources/pyside6/tests/QtCore/bug_462.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -41,7 +16,7 @@ from PySide6.QtCore import QObject, QCoreApplication, QEvent, QThread class MyEvent(QEvent): def __init__(self, i): print("TYPE:", type(QEvent.User)) - super().__init__(QEvent.Type(QEvent.User + 100)) + super().__init__(QEvent.Type(QEvent.User)) self.i = i diff --git a/sources/pyside6/tests/QtCore/bug_505.py b/sources/pyside6/tests/QtCore/bug_505.py index a00973fea..e8655a84e 100644 --- a/sources/pyside6/tests/QtCore/bug_505.py +++ b/sources/pyside6/tests/QtCore/bug_505.py @@ -1,31 +1,7 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +import gc import os import sys import unittest @@ -54,6 +30,8 @@ class CheckForEventsTypes(unittest.TestCase): o = MyBaseObject(p) del o del p + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/bug_515.py b/sources/pyside6/tests/QtCore/bug_515.py index 2e9ff83d6..4e270a441 100644 --- a/sources/pyside6/tests/QtCore/bug_515.py +++ b/sources/pyside6/tests/QtCore/bug_515.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 """ Unittest for bug #515 """ """ http://bugs.openbossa.org/show_bug.cgi?id=515 """ @@ -51,7 +26,7 @@ def _cleanup(): def _checkCleanup(): global callCleanup - assert(callCleanup) + assert (callCleanup) app = QCoreApplication([]) diff --git a/sources/pyside6/tests/QtCore/bug_606.py b/sources/pyside6/tests/QtCore/bug_606.py index f1245456c..4fed16b6e 100644 --- a/sources/pyside6/tests/QtCore/bug_606.py +++ b/sources/pyside6/tests/QtCore/bug_606.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_656.py b/sources/pyside6/tests/QtCore/bug_656.py index d58261dc2..066dc1a02 100644 --- a/sources/pyside6/tests/QtCore/bug_656.py +++ b/sources/pyside6/tests/QtCore/bug_656.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_686.py b/sources/pyside6/tests/QtCore/bug_686.py index e4c027ee1..6425a4b86 100644 --- a/sources/pyside6/tests/QtCore/bug_686.py +++ b/sources/pyside6/tests/QtCore/bug_686.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -50,8 +25,8 @@ class MyWriteThread(QThread): self.started = True while not self.lock.tryLockForWrite(): pass - self.lock.unlock() self.canQuit = True + self.lock.unlock() class MyReadThread(QThread): @@ -65,8 +40,8 @@ class MyReadThread(QThread): self.started = True while not self.lock.tryLockForRead(): pass - self.lock.unlock() self.canQuit = True + self.lock.unlock() class MyMutexedThread(QThread): @@ -93,10 +68,10 @@ class TestQMutex (unittest.TestCase): with QReadLocker(lock): thread.start() while not thread.started: - pass + QThread.msleep(10) self.assertFalse(thread.canQuit) - thread.wait(2000) + self.assertTrue(thread.wait(2000)) self.assertTrue(thread.canQuit) def testWriteLocker(self): @@ -106,10 +81,10 @@ class TestQMutex (unittest.TestCase): with QWriteLocker(lock): thread.start() while not thread.started: - pass + QThread.msleep(10) self.assertFalse(thread.canQuit) - thread.wait(2000) + self.assertTrue(thread.wait(2000)) self.assertTrue(thread.canQuit) def testMutexLocker(self): @@ -119,12 +94,25 @@ class TestQMutex (unittest.TestCase): with QMutexLocker(mutex): thread.start() while not thread.started: - pass + QThread.msleep(10) self.assertFalse(thread.canQuit) - thread.wait(2000) + self.assertTrue(thread.wait(2000)) self.assertTrue(thread.canQuit) + def testWithAsLocker(self): + lock = QReadWriteLock() + with QReadLocker(lock) as locker: + self.assertTrue(isinstance(locker, QReadLocker)) + with QWriteLocker(lock) as locker: + self.assertTrue(isinstance(locker, QWriteLocker)) + mutex = QMutex() + with QMutexLocker(mutex) as locker: + self.assertTrue(isinstance(locker, QMutexLocker)) + with self.assertRaises(TypeError): + with QMutexLocker(lock) as locker: + pass + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_699.py b/sources/pyside6/tests/QtCore/bug_699.py index e624640d2..02da46ff1 100644 --- a/sources/pyside6/tests/QtCore/bug_699.py +++ b/sources/pyside6/tests/QtCore/bug_699.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_706.py b/sources/pyside6/tests/QtCore/bug_706.py index 813181726..7db773240 100644 --- a/sources/pyside6/tests/QtCore/bug_706.py +++ b/sources/pyside6/tests/QtCore/bug_706.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_820.py b/sources/pyside6/tests/QtCore/bug_820.py index dfd6c6b63..ba0d33068 100644 --- a/sources/pyside6/tests/QtCore/bug_820.py +++ b/sources/pyside6/tests/QtCore/bug_820.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import functools import os diff --git a/sources/pyside6/tests/QtCore/bug_826.py b/sources/pyside6/tests/QtCore/bug_826.py index 3b1fb3714..95edc0a7c 100644 --- a/sources/pyside6/tests/QtCore/bug_826.py +++ b/sources/pyside6/tests/QtCore/bug_826.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -43,7 +18,7 @@ TEST_EVENT_TYPE = QEvent.Type(QEvent.registerEventType()) class TestEvent(QEvent): - TestEventType = QEvent.Type(QEvent.registerEventType()) + TestEventType = QEvent.Type(TEST_EVENT_TYPE) def __init__(self, rand=0): super().__init__(TestEvent.TestEventType) @@ -58,10 +33,6 @@ class TestEnums(unittest.TestCase): self.assertTrue(QEvent.User <= TestEvent.TestEventType <= QEvent.MaxUser) self.assertTrue(QEvent.User <= TEST_EVENT_TYPE <= QEvent.MaxUser) - def testUserTypesRepr(self): - self.assertEqual(eval(repr(TestEvent.TestEventType)), TestEvent.TestEventType) - self.assertEqual(eval(repr(TEST_EVENT_TYPE)), TEST_EVENT_TYPE) - if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_829.py b/sources/pyside6/tests/QtCore/bug_829.py index c5636f62a..9a57e0399 100644 --- a/sources/pyside6/tests/QtCore/bug_829.py +++ b/sources/pyside6/tests/QtCore/bug_829.py @@ -1,34 +1,10 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Copyright (C) 2011 Thomas Perl <thp.io/about> -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# Copyright (C) 2011 Thomas Perl <thp.io/about> +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 # Test case for PySide bug 829 +import gc import os import sys import unittest @@ -52,6 +28,8 @@ class QVariantConversions(unittest.TestCase): confFile.close() self._confFileName = confFile.fileName() del confFile + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() s = QSettings(self._confFileName, QSettings.IniFormat) self.assertEqual(s.status(), QSettings.NoError) # Save value @@ -59,6 +37,8 @@ class QVariantConversions(unittest.TestCase): s.sync() self.assertEqual(s.status(), QSettings.NoError) del s + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() # Restore value s = QSettings(self._confFileName, QSettings.IniFormat) diff --git a/sources/pyside6/tests/QtCore/bug_835.py b/sources/pyside6/tests/QtCore/bug_835.py index e2217ed0c..6d91b6e0a 100644 --- a/sources/pyside6/tests/QtCore/bug_835.py +++ b/sources/pyside6/tests/QtCore/bug_835.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_920.py b/sources/pyside6/tests/QtCore/bug_920.py index e3e087c72..23c8d6201 100644 --- a/sources/pyside6/tests/QtCore/bug_920.py +++ b/sources/pyside6/tests/QtCore/bug_920.py @@ -1,32 +1,6 @@ #!/usr/bin/env python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_927.py b/sources/pyside6/tests/QtCore/bug_927.py index 1a9617481..1ecea61b2 100644 --- a/sources/pyside6/tests/QtCore/bug_927.py +++ b/sources/pyside6/tests/QtCore/bug_927.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -36,19 +11,26 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QTime, QRunnable, QThreadPool +from PySide6.QtCore import QRunnable, QThread, QThreadPool + + +thread_function_called = False + + +class thread_function(): + global thread_function_called + thread_function_called = True class Task(QRunnable): def run(self): - t = QTime() - t.start() - time.sleep(2) # Sleep 2 seconds + QThread.sleep(2) # Sleep 2 seconds class QThreadPoolTest(unittest.TestCase): - '''This used to cause a segfault due the ownership control on globalInstance function ''' def testSlowJobs(self): + '''This used to cause a segfault due the ownership control on + globalInstance function''' for i in range(3): task = Task() QThreadPool.globalInstance().start(task) @@ -56,6 +38,13 @@ class QThreadPoolTest(unittest.TestCase): QThreadPool.globalInstance().waitForDone() + def testCallable(self): + global thread_function_called + tp = QThreadPool.globalInstance() + tp.start(thread_function) + tp.waitForDone() + self.assertTrue(thread_function_called) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_931.py b/sources/pyside6/tests/QtCore/bug_931.py index 5f4f3b14c..f233c2a26 100644 --- a/sources/pyside6/tests/QtCore/bug_931.py +++ b/sources/pyside6/tests/QtCore/bug_931.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_938.py b/sources/pyside6/tests/QtCore/bug_938.py index 823a99e3b..3aca25947 100644 --- a/sources/pyside6/tests/QtCore/bug_938.py +++ b/sources/pyside6/tests/QtCore/bug_938.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_953.py b/sources/pyside6/tests/QtCore/bug_953.py index 0a8c3bdcb..a9cacc97e 100644 --- a/sources/pyside6/tests/QtCore/bug_953.py +++ b/sources/pyside6/tests/QtCore/bug_953.py @@ -1,31 +1,7 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +import gc import os import sys @@ -48,6 +24,8 @@ class Dispatcher(QObject): def _finish(self): del self._me # It can't crash here! + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() QTimer.singleShot(10, QCoreApplication.instance().quit) diff --git a/sources/pyside6/tests/QtCore/bug_987.py b/sources/pyside6/tests/QtCore/bug_987.py index 42d1f5fcf..a8c9799e0 100644 --- a/sources/pyside6/tests/QtCore/bug_987.py +++ b/sources/pyside6/tests/QtCore/bug_987.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -44,7 +19,7 @@ class TestBug987(unittest.TestCase): def testInvalidDisconnection(self): o = QObject() - self.assertRaises(RuntimeError, o.destroyed.disconnect, self.callback) + self.assertFalse(o.destroyed.disconnect(self.callback)) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/bug_994.py b/sources/pyside6/tests/QtCore/bug_994.py index adf41b2d3..464fe3120 100644 --- a/sources/pyside6/tests/QtCore/bug_994.py +++ b/sources/pyside6/tests/QtCore/bug_994.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py index 170444fd8..84859af84 100644 --- a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py +++ b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -35,16 +10,19 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QCoreApplication, QEventLoop, QObject, Qt, QThread, QTimer, SIGNAL +from PySide6.QtCore import QCoreApplication, QEventLoop, QObject, Qt, QThread, Signal class Emitter(QThread): + + signal = Signal(int) + def __init__(self): super().__init__() def run(self): print("Before emit.") - self.emit(SIGNAL("signal(int)"), 0) + self.signal.emit(0) print("After emit.") @@ -61,12 +39,11 @@ class Receiver(QObject): class TestBugPYSIDE164(unittest.TestCase): def testBlockingSignal(self): - app = QCoreApplication.instance() or QCoreApplication([]) + app = QCoreApplication.instance() or QCoreApplication([]) # noqa: F841 eventloop = QEventLoop() emitter = Emitter() receiver = Receiver(eventloop) - emitter.connect(emitter, SIGNAL("signal(int)"), - receiver.receive, Qt.BlockingQueuedConnection) + emitter.signal.connect(receiver.receive, Qt.BlockingQueuedConnection) emitter.start() retval = eventloop.exec() emitter.wait(2000) diff --git a/sources/pyside6/tests/QtCore/bug_PYSIDE-41.py b/sources/pyside6/tests/QtCore/bug_PYSIDE-41.py new file mode 100644 index 000000000..2830f8050 --- /dev/null +++ b/sources/pyside6/tests/QtCore/bug_PYSIDE-41.py @@ -0,0 +1,49 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +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) + +from PySide6.QtCore import QPersistentModelIndex, QStringListModel + + +class TestBugPYSIDE41(unittest.TestCase): + + def testIt(self): + + # list of single-character strings + strings = list('abcdefghijklmnopqrstuvwxyz') + + model = QStringListModel(strings) + + # Test hashing of both QModelIndex and QPersistentModelIndex + indexFunctions = [] + indexFunctions.append(model.index) + indexFunctions.append(lambda i: QPersistentModelIndex(model.index(i))) + + for indexFunction in indexFunctions: + + # If two objects compare equal, their hashes MUST also be equal. (The + # reverse is not a requirement.) + for i, _ in enumerate(strings): + index1 = indexFunction(i) + index2 = indexFunction(i) + self.assertEqual(index1, index2) + self.assertEqual(hash(index1), hash(index2)) + + # Adding the full set of indexes to itself is a no-op. + allIndexes1 = set(indexFunction(i) for i, _ in enumerate(strings)) + allIndexes2 = set(indexFunction(i) for i, _ in enumerate(strings)) + allIndexesCombined = allIndexes1 & allIndexes2 + self.assertEqual(allIndexes1, allIndexesCombined) + self.assertEqual(allIndexes2, allIndexesCombined) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/bug_PYSIDE-42.py b/sources/pyside6/tests/QtCore/bug_PYSIDE-42.py index 448312606..b602b7569 100644 --- a/sources/pyside6/tests/QtCore/bug_PYSIDE-42.py +++ b/sources/pyside6/tests/QtCore/bug_PYSIDE-42.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/child_event_test.py b/sources/pyside6/tests/QtCore/child_event_test.py index 29c51e2aa..6b17ddc93 100644 --- a/sources/pyside6/tests/QtCore/child_event_test.py +++ b/sources/pyside6/tests/QtCore/child_event_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test case for QObject.childEvent and QTimer.childEvent overloading''' @@ -40,7 +14,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QObject, QTimer, QCoreApplication -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication class ExtQObject(QObject): @@ -63,14 +37,14 @@ class ExtQTimer(QTimer): self.child_event_received = True -class TestChildEvent(UsesQCoreApplication): +class TestChildEvent(UsesQApplication): '''Test case for QObject::childEvent and QTimer::childEvent''' def setUp(self): - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) def tearDown(self): - UsesQCoreApplication.tearDown(self) + UsesQApplication.tearDown(self) def testQObject(self): parent = ExtQObject() diff --git a/sources/pyside6/tests/QtCore/classinfo_test.py b/sources/pyside6/tests/QtCore/classinfo_test.py index 7fed56bf7..0b0a0b4b6 100644 --- a/sources/pyside6/tests/QtCore/classinfo_test.py +++ b/sources/pyside6/tests/QtCore/classinfo_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import sys import os @@ -57,12 +32,29 @@ class TestClassInfo(unittest.TestCase): self.assertEqual(ci.name(), 'url') self.assertEqual(ci.value(), 'http://www.pyside.org') + def test_dictionary(self): + @ClassInfo({'author': 'pyside', 'author company': 'The Qt Company'}) + class MyObject(QObject): + pass + + o = MyObject() + mo = o.metaObject() + self.assertEqual(mo.classInfoCount(), 2) + + ci = mo.classInfo(0) # author + self.assertEqual(ci.name(), 'author') + self.assertEqual(ci.value(), 'pyside') + + ci = mo.classInfo(1) # url + self.assertEqual(ci.name(), 'author company') + self.assertEqual(ci.value(), 'The Qt Company') + def test_verify_metadata_types(self): - valid_dict = { '123': '456' } + valid_dict = {'123': '456'} - invalid_dict_1 = { '123': 456 } - invalid_dict_2 = { 123: 456 } - invalid_dict_3 = { 123: '456' } + invalid_dict_1 = {'123': 456} + invalid_dict_2 = {123: 456} + invalid_dict_3 = {123: '456'} ClassInfo(**valid_dict) @@ -94,25 +86,28 @@ class TestClassInfo(unittest.TestCase): self.assertRaises(TypeError, decorator, MyObject2) def test_can_only_be_used_on_qobjects(self): + def make_info(): + return ClassInfo(author='pyside') + def test_function(): pass - self.assertRaises(TypeError, ClassInfo(), test_function) + self.assertRaises(TypeError, make_info(), test_function) class NotAQObject(object): pass - self.assertRaises(TypeError, ClassInfo(), NotAQObject) + self.assertRaises(TypeError, make_info(), NotAQObject) class QObjectSubclass(QObject): pass - ClassInfo()(QObjectSubclass) + make_info()(QObjectSubclass) class SubclassOfNativeQObjectSubclass(QCoreApplication): pass - ClassInfo()(SubclassOfNativeQObjectSubclass) + make_info()(SubclassOfNativeQObjectSubclass) class SubclassOfPythonQObjectSubclass(QObjectSubclass): pass - ClassInfo()(SubclassOfPythonQObjectSubclass) + make_info()(SubclassOfPythonQObjectSubclass) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/deepcopy_test.py b/sources/pyside6/tests/QtCore/deepcopy_test.py index ef9a72fb5..e130628e3 100644 --- a/sources/pyside6/tests/QtCore/deepcopy_test.py +++ b/sources/pyside6/tests/QtCore/deepcopy_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 from copy import deepcopy import os diff --git a/sources/pyside6/tests/QtCore/deletelater_test.py b/sources/pyside6/tests/QtCore/deletelater_test.py index 033b0cc70..0ee078428 100644 --- a/sources/pyside6/tests/QtCore/deletelater_test.py +++ b/sources/pyside6/tests/QtCore/deletelater_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QTimer.singleShot''' +import gc import os import sys import unittest @@ -40,16 +15,18 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QObject, QTimer, QCoreApplication, SIGNAL -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication -class TestDeleteLater(UsesQCoreApplication): +class TestDeleteLater(UsesQApplication): '''Test case for function DeleteLater''' def testCase(self): o = QObject() o.deleteLater() del o + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() QTimer.singleShot(100, self.app.quit) self.app.exec() diff --git a/sources/pyside6/tests/QtCore/destroysignal_test.py b/sources/pyside6/tests/QtCore/destroysignal_test.py index ff657a800..ad087b489 100644 --- a/sources/pyside6/tests/QtCore/destroysignal_test.py +++ b/sources/pyside6/tests/QtCore/destroysignal_test.py @@ -1,31 +1,7 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +import gc import os import sys import unittest @@ -35,7 +11,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QTimer, QObject +from PySide6.QtCore import QTimer, QObject, Signal class TestDestroySignal(unittest.TestCase): @@ -48,6 +24,10 @@ class TestDestroySignal(unittest.TestCase): t = QTimer() t.destroyed[QObject].connect(self.onObjectDestroyed) del t + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + # PYSIDE-535: Why do I need to do it twice, here? + gc.collect() self.assertTrue(self._destroyed) def testWithParent(self): @@ -56,9 +36,43 @@ class TestDestroySignal(unittest.TestCase): t = QTimer(p) t.destroyed[QObject].connect(self.onObjectDestroyed) del p + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + # PYSIDE-535: Why do I need to do it twice, here? + gc.collect() self.assertTrue(self._destroyed) +class Foo(QObject): + s = Signal(int) + + def __init__(self): + QObject.__init__(self) + sys.stderr.write(f"__init__ {id(self):x}\n") + + def __del__(self): + sys.stderr.write(f"__del__ {id(self):x}\n") + + def send(self, i): + self.s.emit(i) + + +# PYSIDE-2201/2328: This crashed until we introduced a weak reference. +class TestDestroyNoConnect(unittest.TestCase): + + def testSignalDestroyedMissingReference(self): + # This works since it has one reference more to Foo + Foo().send(43) + # This crashed because we have no reference in the signal. + with self.assertRaises(RuntimeError): + Foo().s.emit(44) + + def testSignalDestroyedinConnect(self): + # PYSIDE-2328: Connect to signal of temporary + with self.assertRaises(RuntimeError): + Foo().s.connect(None) + + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/duck_punching_test.py b/sources/pyside6/tests/QtCore/duck_punching_test.py index ab682026b..145863c3e 100644 --- a/sources/pyside6/tests/QtCore/duck_punching_test.py +++ b/sources/pyside6/tests/QtCore/duck_punching_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test case for duck punching new implementations of C++ virtual methods into object instances.''' +import gc import os import sys import types @@ -41,7 +16,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QObject -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication def MethodType(func, instance, instanceType): @@ -56,18 +31,20 @@ class Duck(QObject): QObject.childEvent(self, event) -class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): +class TestDuckPunchingOnQObjectInstance(UsesQApplication): '''Test case for duck punching new implementations of C++ virtual methods into object instances.''' def setUp(self): # Acquire resources self.duck_childEvent_called = False - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) def tearDown(self): # Release resources del self.duck_childEvent_called - UsesQCoreApplication.tearDown(self) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + UsesQApplication.tearDown(self) def testChildEventMonkeyPatch(self): # Test if the new childEvent injected on QObject instance is called from C++ diff --git a/sources/pyside6/tests/QtCore/emoji_string_test.py b/sources/pyside6/tests/QtCore/emoji_string_test.py index 1c9f6e1ec..78dee1893 100644 --- a/sources/pyside6/tests/QtCore/emoji_string_test.py +++ b/sources/pyside6/tests/QtCore/emoji_string_test.py @@ -1,43 +1,5 @@ -# This Python file uses the following encoding: utf-8 - -############################################################################# -## -## Copyright (C) 2018 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$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only """ emoji-string-test.py diff --git a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py index 72452a588..97c4f942e 100644 --- a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py +++ b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py @@ -1,41 +1,5 @@ -############################################################################# -## -## Copyright (C) 2020 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$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only import os import sys @@ -46,8 +10,14 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) +from PySide6 import QtCore from PySide6.QtWidgets import QApplication, QLabel -from PySide6.support import __feature__ + +is_pypy = hasattr(sys, "pypy_version_info") +if not is_pypy: + from PySide6.support import feature + +import inspect """ errormessages_with_features_test.py @@ -61,16 +31,16 @@ This test is in its own file because combining it with """ +@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy") class ErrormessagesWithFeatures(unittest.TestCase): probe = "called with wrong argument types" - probe_miss = "missing signature" def setUp(self): qApp or QApplication() - __feature__.set_selection(0) + feature.reset() def tearDown(self): - __feature__.set_selection(0) + feature.reset() qApp.shutdown() def testCorrectErrorMessagesPlain(self): @@ -105,20 +75,27 @@ class ErrormessagesWithFeatures(unittest.TestCase): with self.assertRaises(TypeError) as cm: QApplication.quitOnLastWindowClosed = object print("\n\n" + cm.exception.args[0]) - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) with self.assertRaises(TypeError) as cm: qApp.quitOnLastWindowClosed = object - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) def testCorrectErrorMessagesClassSnakeProp(self): from __feature__ import snake_case, true_property with self.assertRaises(TypeError) as cm: QApplication.quit_on_last_window_closed = object print("\n\n" + cm.exception.args[0]) - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) with self.assertRaises(TypeError) as cm: qApp.quit_on_last_window_closed = object - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) + + def testDocIsWorking(self): + """ + make sure that it does not crash when touched + """ + inspect.getdoc(QApplication) + inspect.getdoc(QtCore) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/feature_with_uic/window.py b/sources/pyside6/tests/QtCore/feature_with_uic/window.py new file mode 100644 index 000000000..c55bcaf92 --- /dev/null +++ b/sources/pyside6/tests/QtCore/feature_with_uic/window.py @@ -0,0 +1,52 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QHBoxLayout, QMainWindow, QMenuBar, + QPushButton, QSizePolicy, QStatusBar, QVBoxLayout, + QWidget) + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + if not MainWindow.objectName(): + MainWindow.setObjectName(u"MainWindow") + MainWindow.resize(263, 196) + self.centralwidget = QWidget(MainWindow) + self.centralwidget.setObjectName(u"centralwidget") + self.horizontalLayout = QHBoxLayout(self.centralwidget) + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.verticalLayout = QVBoxLayout() + self.verticalLayout.setObjectName(u"verticalLayout") + self.pushButton = QPushButton(self.centralwidget) + self.pushButton.setObjectName(u"pushButton") + + self.verticalLayout.addWidget(self.pushButton) + + self.horizontalLayout.addLayout(self.verticalLayout) + + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QMenuBar(MainWindow) + self.menubar.setObjectName(u"menubar") + self.menubar.setGeometry(QRect(0, 0, 263, 23)) + MainWindow.setMenuBar(self.menubar) + self.statusbar = QStatusBar(MainWindow) + self.statusbar.setObjectName(u"statusbar") + MainWindow.setStatusBar(self.statusbar) + + self.retranslateUi(MainWindow) + self.pushButton.clicked.connect(MainWindow.close) + + QMetaObject.connectSlotsByName(MainWindow) + # setupUi + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) + self.pushButton.setText(QCoreApplication.translate("MainWindow", u"PushButton", None)) + # retranslateUi + diff --git a/sources/pyside6/tests/QtCore/feature_with_uic/window.ui b/sources/pyside6/tests/QtCore/feature_with_uic/window.ui new file mode 100644 index 000000000..0b85824ea --- /dev/null +++ b/sources/pyside6/tests/QtCore/feature_with_uic/window.ui @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>263</width> + <height>196</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>263</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections> + <connection> + <sender>pushButton</sender> + <signal>clicked()</signal> + <receiver>MainWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel"> + <x>131</x> + <y>97</y> + </hint> + <hint type="destinationlabel"> + <x>131</x> + <y>97</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/sources/pyside6/tests/QtCore/feature_with_uic_test.py b/sources/pyside6/tests/QtCore/feature_with_uic_test.py new file mode 100644 index 000000000..2ffc9970e --- /dev/null +++ b/sources/pyside6/tests/QtCore/feature_with_uic_test.py @@ -0,0 +1,59 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +""" +feature_with_uic_test.py +------------------------ + +Check if feature switching works with a normal UIC file. +This crashed due to callbacks into QApplication. + +PYSIDE-1626: Switch early in `BindingManager::getOverride`. +""" + +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) + +from helper.usesqapplication import UsesQApplication + +from PySide6.QtCore import QCoreApplication, QLibraryInfo, qVersion +from PySide6.QtWidgets import QApplication, QMainWindow + +# PYSIDE-535: We cannot use __feature__ in PyPy, yet +try: + from __feature__ import snake_case + + from feature_with_uic.window import Ui_MainWindow + have_feature = True +except ImportError: + Ui_MainWindow = object + have_feature = False + + +class MainWindow(QMainWindow, Ui_MainWindow): + + def __init__(self) -> None: + super().__init__() + self.setupUi(self) + + +@unittest.skipIf(hasattr(sys, "pypy_version_info"), + "__feature__ cannot yet be used with PyPy") +class FeatureTest(UsesQApplication): + + def testFeaturesWorkWithUIC(self): + window = MainWindow() + window.set_window_title(qVersion()) + window.show() + while not window.window_handle().is_exposed(): + QCoreApplication.process_events() + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/hash_test.py b/sources/pyside6/tests/QtCore/hash_test.py index a6aab9270..aee2f516c 100644 --- a/sources/pyside6/tests/QtCore/hash_test.py +++ b/sources/pyside6/tests/QtCore/hash_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -41,13 +15,17 @@ from PySide6.QtCore import QDate, QDateTime, QTime, QUrl from PySide6.QtCore import QLine, QPoint, QRect, QSize +URL = "https://qt.io/" + + class HashTest(unittest.TestCase): def testInsert(self): myHash = {} qdate = QDate.currentDate() qdatetime = QDateTime.currentDateTime() qtime = QTime.currentTime() - qurl = QUrl("http://www.pyside.org") + qurl = QUrl(URL) + self.assertTrue(qurl.isValid()) qpoint = QPoint(12, 42) myHash[qdate] = "QDate" @@ -90,7 +68,34 @@ class HashTest(unittest.TestCase): self.assertEqual(l1, l2) self.assertEqual(hash(l1), hash(l2)) + def testQTimeHash(self): + t1 = QTime(5, 5, 5) + t2 = QTime(5, 5, 5) + self.assertFalse(t1 is t2) + self.assertEqual(t1, t2) + self.assertEqual(hash(t1), hash(t2)) + + def testQDateHash(self): + d1 = QDate(1968, 3, 9) + d2 = QDate(1968, 3, 9) + self.assertFalse(d1 is d2) + self.assertEqual(d1, d2) + self.assertEqual(hash(d1), hash(d2)) + + def testQDateTimeHash(self): + d1 = QDateTime(QDate(1968, 3, 9), QTime(5, 5, 5)) + d2 = QDateTime(QDate(1968, 3, 9), QTime(5, 5, 5)) + self.assertFalse(d1 is d2) + self.assertEqual(d1, d2) + self.assertEqual(hash(d1), hash(d2)) + + def testQUrlHash(self): + u1 = QUrl(URL) + u2 = QUrl(URL) + self.assertFalse(u1 is u2) + self.assertEqual(u1, u2) + self.assertEqual(hash(u1), hash(u2)) + if __name__ == '__main__': unittest.main() - diff --git a/sources/pyside6/tests/QtCore/inherits_test.py b/sources/pyside6/tests/QtCore/inherits_test.py index 2beea6c17..1422616d8 100644 --- a/sources/pyside6/tests/QtCore/inherits_test.py +++ b/sources/pyside6/tests/QtCore/inherits_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/loggingcategorymacros_test.py b/sources/pyside6/tests/QtCore/loggingcategorymacros_test.py new file mode 100644 index 000000000..a808f0c3d --- /dev/null +++ b/sources/pyside6/tests/QtCore/loggingcategorymacros_test.py @@ -0,0 +1,84 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +"""Tests for category logging macros qCDebug, qCInfo, qCWarning, qCCritical""" + +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) + +from PySide6.QtCore import (QLoggingCategory, QtMsgType, qCDebug, qCWarning, qCInfo, + qCCritical, qInstallMessageHandler) + +param = None + + +def handler(msgt, ctx, msg): + global param + param = ctx.category + ": " + msg.strip() + + +class TestQLoggingCategory(unittest.TestCase): + def setUp(self) -> None: + super().setUp() + self.defaultCategory = QLoggingCategory("default") + self.debugCategory = QLoggingCategory("debug.log", QtMsgType.QtDebugMsg) + self.infoCategory = QLoggingCategory("info.log", QtMsgType.QtInfoMsg) + self.warningCategory = QLoggingCategory("warning.log", QtMsgType.QtWarningMsg) + self.criticalCategory = QLoggingCategory("critical.log", QtMsgType.QtCriticalMsg) + qInstallMessageHandler(handler) + self.no_devices = 2 + + def test_qCDebug(self): + qCDebug(self.defaultCategory, "no device") + self.assertEqual(param, "default: no device") + qCDebug(self.debugCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "debug.log: devices: 2") + + # not updated because category is Info which is above Debug + # nothing will be printed here + qCDebug(self.infoCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "debug.log: devices: 2") + + def test_qCInfo(self): + qCInfo(self.defaultCategory, "no device") + self.assertEqual(param, "default: no device") + qCInfo(self.debugCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "debug.log: devices: 2") + qCInfo(self.infoCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "info.log: devices: 2") + + # not updated because category is Warning which is above Info + # nothing will be printed here + qCInfo(self.warningCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "info.log: devices: 2") + + def test_qCWarning(self): + qCWarning(self.defaultCategory, "no device") + self.assertEqual(param, "default: no device") + qCWarning(self.debugCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "debug.log: devices: 2") + qCWarning(self.warningCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "warning.log: devices: 2") + + # not updated because category is Critical which is above Warning + # nothing will be printed here + qCWarning(self.criticalCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "warning.log: devices: 2") + + def test_qCritical(self): + qCCritical(self.defaultCategory, "no device") + self.assertEqual(param, "default: no device") + qCCritical(self.warningCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "warning.log: devices: 2") + qCCritical(self.criticalCategory, f"devices: {self.no_devices}") + self.assertEqual(param, "critical.log: devices: 2") + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/max_signals.py b/sources/pyside6/tests/QtCore/max_signals.py index b5b5f00d8..95952dfbf 100644 --- a/sources/pyside6/tests/QtCore/max_signals.py +++ b/sources/pyside6/tests/QtCore/max_signals.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/missing_symbols_test.py b/sources/pyside6/tests/QtCore/missing_symbols_test.py index 8e03edf9c..7cf6d3e3e 100644 --- a/sources/pyside6/tests/QtCore/missing_symbols_test.py +++ b/sources/pyside6/tests/QtCore/missing_symbols_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''(Very) Simple test case for missing names from QtCore''' diff --git a/sources/pyside6/tests/QtCore/mockclass_test.py b/sources/pyside6/tests/QtCore/mockclass_test.py index 887de6bca..c7e465b24 100644 --- a/sources/pyside6/tests/QtCore/mockclass_test.py +++ b/sources/pyside6/tests/QtCore/mockclass_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 # Test case for PySide bug 634 # http://bugs.pyside.org/show_bug.cgi?id=634 diff --git a/sources/pyside6/tests/QtCore/multiple_feature_test.py b/sources/pyside6/tests/QtCore/multiple_feature_test.py index 0a66075ae..0f51ace6b 100644 --- a/sources/pyside6/tests/QtCore/multiple_feature_test.py +++ b/sources/pyside6/tests/QtCore/multiple_feature_test.py @@ -1,41 +1,5 @@ -############################################################################# -## -## Copyright (C) 2020 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$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only import os import sys @@ -47,7 +11,11 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QCborArray, QObject -from PySide6.support import __feature__ + +is_pypy = hasattr(sys, "pypy_version_info") +if not is_pypy: + from PySide6.support import feature + from textwrap import dedent """ @@ -63,6 +31,12 @@ There is much more to come. MethodDescriptorType = type(str.split) +def xprint(*args, **kw): + if "-v" in sys.argv: + print(*args, **kw) + + +@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy") class FeaturesTest(unittest.TestCase): def testAllFeatureCombinations(self): @@ -117,21 +91,21 @@ class FeaturesTest(unittest.TestCase): """), "<string>", "exec"), globals(), edict) globals().update(edict) - feature_list = __feature__._really_all_feature_names + feature_list = feature._really_all_feature_names func_list = [tst_bit0, tst_bit1, tst_bit2, tst_bit3, tst_bit4, tst_bit5, tst_bit6, tst_bit7] for idx in range(0x100): - __feature__.set_selection(0) + feature.reset() config = f"feature_{idx:02x}" - print() - print(f"--- Feature Test Config `{config}` ---") - print("Imports:") + xprint() + xprint(f"--- Feature Test Config `{config}` ---") + xprint("Imports:") for bit in range(8): if idx & 1 << bit: - feature = feature_list[bit] - text = f"from __feature__ import {feature}" - print(text) + cur_feature = feature_list[bit] + text = f"from __feature__ import {cur_feature}" + xprint(text) eval(compile(text, "<string>", "exec"), globals(), edict) for bit in range(8): value = idx & 1 << bit diff --git a/sources/pyside6/tests/QtCore/python_conversion.py b/sources/pyside6/tests/QtCore/python_conversion.py index 1e081bac2..28a271b61 100644 --- a/sources/pyside6/tests/QtCore/python_conversion.py +++ b/sources/pyside6/tests/QtCore/python_conversion.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QLineF''' diff --git a/sources/pyside6/tests/QtCore/qabs_test.py b/sources/pyside6/tests/QtCore/qabs_test.py index 3320addb0..2b22b1e17 100644 --- a/sources/pyside6/tests/QtCore/qabs_test.py +++ b/sources/pyside6/tests/QtCore/qabs_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py b/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py index bffad74ec..bb9a2222a 100644 --- a/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py +++ b/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py @@ -1,32 +1,5 @@ -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qanimationgroup_test.py b/sources/pyside6/tests/QtCore/qanimationgroup_test.py index 972571ac6..9b9b0e622 100644 --- a/sources/pyside6/tests/QtCore/qanimationgroup_test.py +++ b/sources/pyside6/tests/QtCore/qanimationgroup_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qbitarray_test.py b/sources/pyside6/tests/QtCore/qbitarray_test.py index 580fa1f5b..70452eab1 100644 --- a/sources/pyside6/tests/QtCore/qbitarray_test.py +++ b/sources/pyside6/tests/QtCore/qbitarray_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' +import gc import os import sys import unittest @@ -79,6 +54,8 @@ class QBitArrayIsIterableTest(unittest.TestCase): del self.qbitarray_values del self.other_qbitarray_values del self.inverted_qbitarray_values + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testQBitArrayIsIterable(self): # Tests if QBitArray class is iterable diff --git a/sources/pyside6/tests/QtCore/qbytearray_concatenation_operator_test.py b/sources/pyside6/tests/QtCore/qbytearray_concatenation_operator_test.py index 9fdfda64e..aea9778d7 100644 --- a/sources/pyside6/tests/QtCore/qbytearray_concatenation_operator_test.py +++ b/sources/pyside6/tests/QtCore/qbytearray_concatenation_operator_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QByteArray concatenation with '+' operator''' diff --git a/sources/pyside6/tests/QtCore/qbytearray_operator_iadd_test.py b/sources/pyside6/tests/QtCore/qbytearray_operator_iadd_test.py index c7107872c..a2201a716 100644 --- a/sources/pyside6/tests/QtCore/qbytearray_operator_iadd_test.py +++ b/sources/pyside6/tests/QtCore/qbytearray_operator_iadd_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qbytearray_operator_test.py b/sources/pyside6/tests/QtCore/qbytearray_operator_test.py index 0053b1351..0064e4dd6 100644 --- a/sources/pyside6/tests/QtCore/qbytearray_operator_test.py +++ b/sources/pyside6/tests/QtCore/qbytearray_operator_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QByteArray operators''' diff --git a/sources/pyside6/tests/QtCore/qbytearray_test.py b/sources/pyside6/tests/QtCore/qbytearray_test.py index c347a6e4d..cb8f9a431 100644 --- a/sources/pyside6/tests/QtCore/qbytearray_test.py +++ b/sources/pyside6/tests/QtCore/qbytearray_test.py @@ -1,39 +1,12 @@ -# -*- coding:utf-8 -*- -# !/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QByteArray''' import ctypes import os import pickle +import struct import sys import unittest @@ -43,7 +16,8 @@ from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QByteArray, QSettings, QObject, QDataStream, QIODevice +from PySide6.QtCore import (QByteArray, QSettings, QObject, QDataStream, + QIODevice, qCompress, qUncompress) class QByteArrayTestToNumber(unittest.TestCase): @@ -233,7 +207,7 @@ class QByteArraySliceAssignment(unittest.TestCase): # shrink b[2:8] = QByteArray(bytes('aaa', "UTF8")) self.assertEqual(b, bytes('01aaa89', "UTF8")) - # expanse + # expand b[2:5] = QByteArray(bytes('uvwxyz', "UTF8")) self.assertEqual(b, bytes('01uvwxyz89', "UTF8")) # Delete behavior @@ -241,7 +215,7 @@ class QByteArraySliceAssignment(unittest.TestCase): self.assertEqual(b, bytes('0189', "UTF8")) b = QByteArray(bytes('0123456789', "UTF8")) - # reverse assginment + # reverse assignment b[5:2:-1] = QByteArray(bytes('ABC', "UTF8")) self.assertEqual(b, bytes('012CBA6789', "UTF8")) # step is not 1 @@ -259,7 +233,7 @@ class QByteArraySliceAssignment(unittest.TestCase): # shrink b[2:8] = bytearray(bytes('aaa', "UTF8")) self.assertEqual(b, bytes('01aaa89', "UTF8")) - # expanse + # expand b[2:5] = bytearray(bytes('uvwxyz', "UTF8")) self.assertEqual(b, bytes('01uvwxyz89', "UTF8")) # Delete behavior @@ -267,7 +241,7 @@ class QByteArraySliceAssignment(unittest.TestCase): self.assertEqual(b, bytes('0189', "UTF8")) b = QByteArray(bytes('0123456789', "UTF8")) - # reverse assginment + # reverse assignment b[5:2:-1] = bytearray(bytes('ABC', "UTF8")) self.assertEqual(b, bytes('012CBA6789', "UTF8")) # step is not 1 @@ -283,6 +257,34 @@ class QByteArraySliceAssignment(unittest.TestCase): actual_bytes = bytes(byte_array) self.assertEqual(orig_bytes, actual_bytes) + def testUnpack(self): + b = QByteArray(b'\x19\x00\x00\x00\xc4\t\x00\x00') + t = struct.unpack('<ii', b) + self.assertEqual(len(t), 2) + self.assertEqual(t[0], 25) + self.assertEqual(t[1], 2500) + + +class QCompressTest(unittest.TestCase): + def testQByteArrayCompression(self): + """Compress/uncompress a QByteArray.""" + data = bytes(10 * 'long redundant sentence bla bla', "UTF8") + ba = QByteArray(data) + compressed = qCompress(ba) + self.assertTrue(len(compressed) < len(data)) + uncompressed = qUncompress(compressed) + self.assertEqual(uncompressed, data) + + def testBufferCompression(self): + """Compress/uncompress portions of bytes without converting to + QByteArray.""" + data = bytes(10 * 'long redundant sentence bla bla', "UTF8") + used_len = int(len(data) / 2) + compressed = qCompress(data, used_len, -1) + self.assertTrue(len(compressed) < used_len) + uncompressed = qUncompress(compressed.data(), len(compressed)) + self.assertEqual(uncompressed, data[:used_len]) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/qcalendar_test.py b/sources/pyside6/tests/QtCore/qcalendar_test.py index 2c69a2026..0137677f3 100644 --- a/sources/pyside6/tests/QtCore/qcalendar_test.py +++ b/sources/pyside6/tests/QtCore/qcalendar_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2019 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QCalendar (5.14)''' diff --git a/sources/pyside6/tests/QtCore/qcbor_test.py b/sources/pyside6/tests/QtCore/qcbor_test.py index 0df9d9f95..312c9e5c7 100644 --- a/sources/pyside6/tests/QtCore/qcbor_test.py +++ b/sources/pyside6/tests/QtCore/qcbor_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QCbor''' +import gc import os import sys import unittest @@ -40,7 +15,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import (QByteArray, QCborStreamReader, QCborStreamWriter, - QCborValue) + QCborTag, QCborValue) class TestCbor(unittest.TestCase): @@ -49,6 +24,8 @@ class TestCbor(unittest.TestCase): writer = QCborStreamWriter(ba) writer.append(42) del writer + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertTrue(not ba.isEmpty()) reader = QCborStreamReader(ba) self.assertTrue(reader.hasNext()) @@ -60,6 +37,8 @@ class TestCbor(unittest.TestCase): writer = QCborStreamWriter(ba) writer.append("hello") del writer + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertTrue(not ba.isEmpty()) reader = QCborStreamReader(ba) self.assertTrue(reader.hasNext()) diff --git a/sources/pyside6/tests/QtCore/qcollator_test.py b/sources/pyside6/tests/QtCore/qcollator_test.py index b9fc29658..9d1052b24 100644 --- a/sources/pyside6/tests/QtCore/qcollator_test.py +++ b/sources/pyside6/tests/QtCore/qcollator_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QCollator''' diff --git a/sources/pyside6/tests/QtCore/qcommandlineparser_test.py b/sources/pyside6/tests/QtCore/qcommandlineparser_test.py index 8021aad74..c562065ae 100644 --- a/sources/pyside6/tests/QtCore/qcommandlineparser_test.py +++ b/sources/pyside6/tests/QtCore/qcommandlineparser_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QCommandLineParser and QCommandLineOption''' diff --git a/sources/pyside6/tests/QtCore/qcoreapplication_argv_test.py b/sources/pyside6/tests/QtCore/qcoreapplication_argv_test.py index e013fdb71..3c8500923 100644 --- a/sources/pyside6/tests/QtCore/qcoreapplication_argv_test.py +++ b/sources/pyside6/tests/QtCore/qcoreapplication_argv_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qcoreapplication_instance_test.py b/sources/pyside6/tests/QtCore/qcoreapplication_instance_test.py index 8e89a260e..968765020 100644 --- a/sources/pyside6/tests/QtCore/qcoreapplication_instance_test.py +++ b/sources/pyside6/tests/QtCore/qcoreapplication_instance_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QCoreApplication.instance static method''' diff --git a/sources/pyside6/tests/QtCore/qcoreapplication_test.py b/sources/pyside6/tests/QtCore/qcoreapplication_test.py index 30e000c31..edd4dc8e2 100644 --- a/sources/pyside6/tests/QtCore/qcoreapplication_test.py +++ b/sources/pyside6/tests/QtCore/qcoreapplication_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qdatastream_test.py b/sources/pyside6/tests/QtCore/qdatastream_test.py index cd0e3e0cb..517f466aa 100644 --- a/sources/pyside6/tests/QtCore/qdatastream_test.py +++ b/sources/pyside6/tests/QtCore/qdatastream_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QDataStream''' @@ -35,8 +9,10 @@ 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) from PySide6.QtCore import QBitArray, QByteArray, QIODevice, QDataStream, QDate, QTime, QDateTime @@ -275,7 +251,6 @@ class QDataStreamShift(unittest.TestCase): class QDataStreamShiftBitArray(unittest.TestCase): - def _check_bitarray(self, data_set): '''Check the >> operator for the given data set''' @@ -308,7 +283,7 @@ class QDataStreamShiftBitArray(unittest.TestCase): self._check_bitarray([(serialized, QDataStream.ReadPastEnd, QBitArray())]) -class QDataStreamRawData(unittest.TestCase): +class QDataStreamBuffer(unittest.TestCase): def testRawData(self): data = QDataStream() self.assertEqual(data.readRawData(4), None) @@ -321,7 +296,31 @@ class QDataStreamRawData(unittest.TestCase): data = QDataStream(ba) self.assertEqual(data.readRawData(4), bytes('AB\x00C', "UTF-8")) + def testRawDataBytes(self): + test_data = b'AB\0' + data = QDataStream() + ba = QByteArray() + data = QDataStream(ba, QIODevice.WriteOnly) + data.writeRawData(test_data) + self.assertEqual(ba.data(), test_data) + data = QDataStream(ba) + self.assertEqual(data.readRawData(3), test_data) + + def testBytes(self): + dataOne = QDataStream() + self.assertEqual(dataOne.readBytes(4), None) + + ba = QByteArray() + data = QDataStream(ba, QIODevice.WriteOnly) + # writeBytes() writes a quint32 containing the length of the data, + # followed by the data. + data.writeBytes(bytes('AB\x00C', 'UTF-8')) + self.assertEqual(ba.data(), bytes('\x00\x00\x00\x04AB\x00C', 'UTF-8')) + + data = QDataStream(ba) + buffer = data.readBytes(4) + self.assertEqual(buffer, bytes('AB\x00C', 'UTF-8')) + if __name__ == '__main__': unittest.main() - diff --git a/sources/pyside6/tests/QtCore/qdate_test.py b/sources/pyside6/tests/QtCore/qdate_test.py index b5259163a..611292227 100644 --- a/sources/pyside6/tests/QtCore/qdate_test.py +++ b/sources/pyside6/tests/QtCore/qdate_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QDate''' diff --git a/sources/pyside6/tests/QtCore/qdatetime_test.py b/sources/pyside6/tests/QtCore/qdatetime_test.py index 362b1fb4c..96e353112 100644 --- a/sources/pyside6/tests/QtCore/qdatetime_test.py +++ b/sources/pyside6/tests/QtCore/qdatetime_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import datetime import os diff --git a/sources/pyside6/tests/QtCore/qdir_test.py b/sources/pyside6/tests/QtCore/qdir_test.py index 169959dbf..702c7f13a 100644 --- a/sources/pyside6/tests/QtCore/qdir_test.py +++ b/sources/pyside6/tests/QtCore/qdir_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qeasingcurve_test.py b/sources/pyside6/tests/QtCore/qeasingcurve_test.py index 46f8f5b90..b202dbefb 100644 --- a/sources/pyside6/tests/QtCore/qeasingcurve_test.py +++ b/sources/pyside6/tests/QtCore/qeasingcurve_test.py @@ -1,34 +1,10 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys import unittest +import gc from pathlib import Path sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) @@ -58,6 +34,8 @@ class TestQEasingCurve(unittest.TestCase): ec.setCustomType(myFunction) self.assertEqual(ec.valueForProgress(1.0), 100.0) self.assertEqual(ec.valueForProgress(0.5), -100.0) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/qenum_test.py b/sources/pyside6/tests/QtCore/qenum_test.py index 0d524505a..45a8e9124 100644 --- a/sources/pyside6/tests/QtCore/qenum_test.py +++ b/sources/pyside6/tests/QtCore/qenum_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2020 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QEnum and QFlags''' @@ -45,20 +19,6 @@ from PySide6.QtCore import Qt, QIODevice, QObject, QEnum, QFlag class TestEnum(unittest.TestCase): - - def testToInt(self): - self.assertEqual(QIODevice.NotOpen, 0) - self.assertEqual(QIODevice.ReadOnly, 1) - self.assertEqual(QIODevice.WriteOnly, 2) - self.assertEqual(QIODevice.ReadWrite, 1 | 2) - self.assertEqual(QIODevice.Append, 4) - self.assertEqual(QIODevice.Truncate, 8) - self.assertEqual(QIODevice.Text, 16) - self.assertEqual(QIODevice.Unbuffered, 32) - - def testToIntInFunction(self): - self.assertEqual(str(int(QIODevice.WriteOnly)), "2") - def testOperations(self): k = Qt.Key.Key_1 @@ -67,16 +27,6 @@ class TestEnum(unittest.TestCase): self.assertEqual(k - 2, -(2 - k)) self.assertEqual(k * 2, 2 * k) - # Floats - with self.assertRaises(TypeError): - a = k + 2.0 - - with self.assertRaises(TypeError): - a = k - 2.0 - - with self.assertRaises(TypeError): - a = k * 2.0 - @unittest.skipUnless(getattr(sys, "getobjects", None), "requires --with-trace-refs") @unittest.skipUnless(getattr(sys, "gettotalrefcount", None), "requires --with-pydebug") def testEnumNew_NoLeak(self): @@ -97,18 +47,20 @@ class TestEnum(unittest.TestCase): class TestQFlags(unittest.TestCase): + def testToItn(self): om = QIODevice.NotOpen + omcmp = om.value 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), 2) def testNonExtensibleEnums(self): try: @@ -158,6 +110,8 @@ except ImportError: Enum.__module__ = "enum" Enum.__members__ = {} del Enum + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() enum.auto = lambda: 42 HAVE_FLAG = hasattr(enum, "Flag") @@ -197,16 +151,15 @@ class SomeClass(QObject): QEnum(SomeEnum) # works even without the decorator assignment -@unittest.skipUnless(HAVE_ENUM, "requires 'enum' module (use 'pip install enum34' for Python 2)") class TestQEnumMacro(unittest.TestCase): + meta_name = "EnumType" if sys.version_info[:2] >= (3, 11) else "EnumMeta" + def testTopLevel(self): - self.assertEqual(type(OuterEnum).__module__, "enum") - self.assertEqual(type(OuterEnum).__name__, "EnumMeta") + self.assertEqual(type(OuterEnum).__name__, self.meta_name) self.assertEqual(len(OuterEnum.__members__), 2) def testSomeClass(self): - self.assertEqual(type(SomeClass.SomeEnum).__module__, "enum") - self.assertEqual(type(SomeClass.SomeEnum).__name__, "EnumMeta") + self.assertEqual(type(SomeClass.SomeEnum).__name__, self.meta_name) self.assertEqual(len(SomeClass.SomeEnum.__members__), 3) with self.assertRaises(TypeError): int(SomeClass.SomeEnum.C) == 6 diff --git a/sources/pyside6/tests/QtCore/qevent_test.py b/sources/pyside6/tests/QtCore/qevent_test.py index 2d7aff03f..244a14f13 100644 --- a/sources/pyside6/tests/QtCore/qevent_test.py +++ b/sources/pyside6/tests/QtCore/qevent_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QtCore.QEvent''' diff --git a/sources/pyside6/tests/QtCore/qfile_test.py b/sources/pyside6/tests/QtCore/qfile_test.py index d480d5e30..0af5c2650 100644 --- a/sources/pyside6/tests/QtCore/qfile_test.py +++ b/sources/pyside6/tests/QtCore/qfile_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qfileinfo_test.py b/sources/pyside6/tests/QtCore/qfileinfo_test.py index d28be7c4c..dfdfd7fa2 100644 --- a/sources/pyside6/tests/QtCore/qfileinfo_test.py +++ b/sources/pyside6/tests/QtCore/qfileinfo_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qfileread_test.py b/sources/pyside6/tests/QtCore/qfileread_test.py index 98b27896c..c66a27f8a 100644 --- a/sources/pyside6/tests/QtCore/qfileread_test.py +++ b/sources/pyside6/tests/QtCore/qfileread_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qflags_test.py b/sources/pyside6/tests/QtCore/qflags_test.py index bde6abde1..2a5306685 100644 --- a/sources/pyside6/tests/QtCore/qflags_test.py +++ b/sources/pyside6/tests/QtCore/qflags_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QFlags''' @@ -111,6 +85,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): @@ -119,15 +112,19 @@ class QFlagsOnQVariant(unittest.TestCase): self.assertEqual(type(o.property("foo")), QIODevice.OpenMode) -class QFlagsWrongType(unittest.TestCase): - def testWrongType(self): - '''Wrong type passed to QFlags binary operators''' - for op in operator.or_, operator.and_, operator.xor: - for x in '43', 'jabba', QObject, object: - self.assertRaises(TypeError, op, Qt.NoItemFlags, x) - self.assertRaises(TypeError, op, x, Qt.NoItemFlags) - # making sure this actually does not fail all the time - self.assertEqual(operator.or_(Qt.NoItemFlags, 43), 43) +class QEnumFlagDefault(unittest.TestCase): + """ + Check that old flag and enum syntax can be used. + The signatures of these surrogate functions intentionally do not exist + because people should learn to use the new Enums correctly. + """ + def testOldQFlag(self): + self.assertEqual(Qt.AlignmentFlag(), Qt.AlignmentFlag(0)) + oldFlag = Qt.Alignment() + oldEnum = Qt.AlignmentFlag() + self.assertEqual(type(oldFlag), Qt.Alignment) + self.assertEqual(type(oldEnum), Qt.AlignmentFlag) + self.assertEqual(type(oldFlag), type(oldEnum)) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/qhandle_test.py b/sources/pyside6/tests/QtCore/qhandle_test.py index 9f6708787..e0f4f3f7a 100644 --- a/sources/pyside6/tests/QtCore/qhandle_test.py +++ b/sources/pyside6/tests/QtCore/qhandle_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QEnum and QFlags''' diff --git a/sources/pyside6/tests/QtCore/qinstallmsghandler_test.py b/sources/pyside6/tests/QtCore/qinstallmsghandler_test.py index df636cdd1..9c5ae4370 100644 --- a/sources/pyside6/tests/QtCore/qinstallmsghandler_test.py +++ b/sources/pyside6/tests/QtCore/qinstallmsghandler_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for qInstallMsgHandler''' @@ -37,9 +12,9 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import (QLibraryInfo, QtCriticalMsg, QtDebugMsg, QtInfoMsg, +from PySide6.QtCore import (QLibraryInfo, QtMsgType, QMessageLogContext, - QtWarningMsg, qCritical, qFormatLogMessage, qDebug, + qCritical, qFormatLogMessage, qDebug, qInstallMessageHandler, qWarning) @@ -65,6 +40,7 @@ class QInstallMsgHandlerTest(unittest.TestCase): ret = qInstallMessageHandler(None) self.assertEqual(ret, None) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testRet(self): ret = qInstallMessageHandler(None) self.assertEqual(ret, None) @@ -80,18 +56,18 @@ class QInstallMsgHandlerTest(unittest.TestCase): rethandler = qInstallMessageHandler(handler) if QLibraryInfo.isDebugBuild(): qDebug("Test Debug") - self.assertEqual(param[0], QtDebugMsg) + self.assertEqual(param[0], QtMsgType.QtDebugMsg) self.assertEqual(param[2], "Test Debug") qWarning("Test Warning") - self.assertEqual(param[0], QtWarningMsg) + self.assertEqual(param[0], QtMsgType.QtWarningMsg) self.assertEqual(param[2], "Test Warning") qCritical("Test Critical") - self.assertEqual(param[0], QtCriticalMsg) + self.assertEqual(param[0], QtMsgType.QtCriticalMsg) self.assertEqual(param[2], "Test Critical") def testFormat(self): ctx = QMessageLogContext() - s = qFormatLogMessage(QtInfoMsg, ctx, 'bla') + s = qFormatLogMessage(QtMsgType.QtInfoMsg, ctx, 'bla') self.assertTrue(s) diff --git a/sources/pyside6/tests/QtCore/qiodevice_buffered_read_test.py b/sources/pyside6/tests/QtCore/qiodevice_buffered_read_test.py new file mode 100644 index 000000000..ea735112a --- /dev/null +++ b/sources/pyside6/tests/QtCore/qiodevice_buffered_read_test.py @@ -0,0 +1,78 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Test cases for buffered read methods of QIODevice''' + +from PySide6.QtCore import QBuffer + +import enum +import unittest + + +class TestQIODeviceBufferedRead(unittest.TestCase): + class TestType(enum.Enum): + Read = enum.auto() + ReadLine = enum.auto() + Peek = enum.auto() + + def setUp(self) -> None: + self.buffer = QBuffer() + self.text = "Tomato juice\nPotato salad\n" + + self.assertTrue( + self.buffer.open(QBuffer.OpenModeFlag.ReadWrite), self.buffer.errorString()) + self.assertGreaterEqual( + self.buffer.write(self.text.encode("utf-8")), 0, self.buffer.errorString()) + + self.buffer.seek(0) + + def tearDown(self) -> None: + self.buffer.close() + + def test_read(self) -> None: + response1 = self.buffer.read(1024).data().decode("utf-8") + self.assertEqual(response1, self.text) + + self.buffer.seek(0) + response2 = bytearray(1024) + bytes_read = self.buffer.read(response2, 1024) + + self.assertGreaterEqual(bytes_read, 0, self.buffer.errorString()) + self.assertEqual(response2[:bytes_read].decode("utf-8"), response1) + + def test_readLine(self) -> None: + response1 = self.buffer.readLine(1024).data().decode("utf-8") + # Only read until the first line (including the line break) + self.assertEqual(response1, self.text.split("\n", 1)[0] + "\n") + + self.buffer.seek(0) + response2 = bytearray(1024) + bytes_read = self.buffer.readLine(response2, 1024) + + self.assertGreaterEqual(bytes_read, 0, self.buffer.errorString()) + self.assertEqual(response2[:bytes_read].decode("utf-8"), response1) + + def test_peek(self) -> None: + response1 = self.buffer.peek(1024).data().decode("utf-8") + self.assertEqual(response1, self.text) + + # Test that peek has no side effects + response_again1 = self.buffer.read(1024).data().decode("utf-8") + self.assertEqual(response_again1, response1) + + self.buffer.seek(0) + response2 = bytearray(1024) + bytes_read = self.buffer.peek(response2, 1024) + + self.assertGreaterEqual(bytes_read, 0, self.buffer.errorString()) + self.assertEqual(response2[:bytes_read].decode("utf-8"), response1) + + # Test that peek has no side effects + response_again2 = bytearray(1024) + bytes_read_again2 = self.buffer.read(response_again2, 1024) + self.assertEqual(bytes_read, bytes_read_again2) + self.assertEqual(response_again2, response2) + + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside6/tests/QtCore/qiopipe_test.py b/sources/pyside6/tests/QtCore/qiopipe_test.py new file mode 100644 index 000000000..53a6ba70a --- /dev/null +++ b/sources/pyside6/tests/QtCore/qiopipe_test.py @@ -0,0 +1,36 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Test cases for the QIOPipe class''' + +from PySide6.QtCore import QIODevice, QIOPipe + +import unittest + + +class QIOPipeTest(unittest.TestCase): + def setUp(self) -> None: + self.pipe = QIOPipe() + self.pipe.open(QIODevice.OpenModeFlag.ReadWrite) + return super().setUp() + + def tearDown(self) -> None: + super().tearDown() + + def ready_read_bytes_written(self): + received_data = self.pipe.end2().readAll().data() + self.assertEqual(received_data, self.data) + + def test_readyRead(self): + self.data = b"Hello, World!" + self.pipe.end2().readyRead.connect(self.ready_read_bytes_written) + self.pipe.end1().write(self.data) + + def test_bytesWritten(self): + self.data = b"Hello, World!" + self.pipe.end2().bytesWritten.connect(self.ready_read_bytes_written) + self.pipe.end1().write(self.data) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/qjsondocument_test.py b/sources/pyside6/tests/QtCore/qjsondocument_test.py index 334ba07ec..a50f185ff 100644 --- a/sources/pyside6/tests/QtCore/qjsondocument_test.py +++ b/sources/pyside6/tests/QtCore/qjsondocument_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QJsonDocument/nullptr_t''' diff --git a/sources/pyside6/tests/QtCore/qlinef_test.py b/sources/pyside6/tests/QtCore/qlinef_test.py index 0a2e91a82..90ae50159 100644 --- a/sources/pyside6/tests/QtCore/qlinef_test.py +++ b/sources/pyside6/tests/QtCore/qlinef_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QLineF''' diff --git a/sources/pyside6/tests/QtCore/qlocale_test.py b/sources/pyside6/tests/QtCore/qlocale_test.py index 0e1603846..05b0d3219 100644 --- a/sources/pyside6/tests/QtCore/qlocale_test.py +++ b/sources/pyside6/tests/QtCore/qlocale_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QLocale''' @@ -63,6 +37,11 @@ class QLocaleTestToNumber(unittest.TestCase): self.assertEqual((ctypes.c_short(37).value, True), obj.toShort('37')) + def testToNumberLong(self): + obj = QLocale(QLocale.C) + self.assertEqual((ctypes.c_long(37).value, True), + obj.toLong('37')) + def testToNumberULongLong(self): obj = QLocale(QLocale.C) self.assertEqual((ctypes.c_ulonglong(37).value, True), @@ -72,6 +51,23 @@ class QLocaleTestToNumber(unittest.TestCase): obj = QLocale(QLocale.C) self.assertTrue(not obj.toULongLong('-37')[1]) + def testToCurrencyString(self): + """PYSIDE-2133, do not use int overload, dropping decimals.""" + en_locale = QLocale("en_US") + value = en_locale.toCurrencyString(1234.56) + self.assertEqual(value, "$1,234.56") + + def testToString(self): + """PYSIDE-2168, check negative values""" + en_locale = QLocale("en_US") + value = en_locale.toString(-4) + self.assertEqual(value, "-4") + # Verify that large types (long long/double) are used. + value = en_locale.toString(3000000000) + self.assertEqual(value, "3,000,000,000") + value = en_locale.toString(10e40) + self.assertEqual(value, "1E+41") + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/qlockfile_test.py b/sources/pyside6/tests/QtCore/qlockfile_test.py index f773c7112..6dca9235c 100644 --- a/sources/pyside6/tests/QtCore/qlockfile_test.py +++ b/sources/pyside6/tests/QtCore/qlockfile_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QLockFile''' @@ -58,6 +32,9 @@ class TestQMessageAuthenticationCode (unittest.TestCase): lockFile = QLockFile(self._fileName) self.assertTrue(lockFile.lock()) self.assertTrue(lockFile.isLocked()) + lock_info = lockFile.getLockInfo(); + self.assertEqual(len(lock_info), 3) + self.assertEqual(lock_info[0], os.getpid()) lockFile.unlock() diff --git a/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py b/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py index 89e3d7ba1..74e6bceb9 100644 --- a/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py +++ b/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QMessageAuthenticationCode''' diff --git a/sources/pyside6/tests/QtCore/qmetaobject_test.py b/sources/pyside6/tests/QtCore/qmetaobject_test.py index 33c35595f..4b3051711 100644 --- a/sources/pyside6/tests/QtCore/qmetaobject_test.py +++ b/sources/pyside6/tests/QtCore/qmetaobject_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Tests for static methos conflicts with class methods''' @@ -40,7 +13,10 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QFile, QObject, QTimer, SIGNAL +from PySide6.QtCore import (QCoreApplication, QFile, QMetaMethod, QMetaObject, + QObject, QModelIndex, QPoint, QTimer, QSemaphore, + QStringListModel, Qt, Signal, Slot, + SIGNAL, Q_ARG, Q_RETURN_ARG) class Foo(QFile): @@ -52,6 +28,57 @@ class DynObject(QObject): pass +class InvokeTester(QObject): + def __init__(self, parent=None): + super().__init__(parent) + + @Slot(int, int, result=int) + def add(self, a, b): + return a + b + + @Slot(str, str, result=str) + def concatenate(self, a, b): + return a + b + + @Slot(QPoint, result=int) + def manhattan_length(self, point): + return abs(point.x()) + abs(point.y()) + + @Slot(QPoint, QPoint, result=QPoint) + def add_points(self, point1, point2): + return point1 + point2 + + @Slot(QObject, result=str) + def object_name(self, o): + return o.objectName() + + @Slot(QObject, result=QObject) + def first_child(self, o): + return o.children()[0] + + +class SemaphoreSender(QObject): + signal = Signal(QSemaphore) + + def __init__(self, parent=None): + super().__init__(parent) + self.semaphore = QSemaphore() + + def emitSignal(self): + self.signal.emit(self.semaphore) + + +class SemaphoreReceiver(QObject): + + def __init__(self, parent=None): + super().__init__(parent) + self.semaphore = None + + @Slot(QSemaphore) + def receiverSlot(self, semaphore): + self.semaphore = semaphore + + class qmetaobject_test(unittest.TestCase): """ def test_QMetaObject(self): @@ -78,15 +105,6 @@ class qmetaobject_test(unittest.TestCase): o.connect(o2, SIGNAL("bars()"), o.slot) self.assertTrue(o2.metaObject().indexOfMethod("bars()") > -1) - #self.assertTrue(o.metaObject().indexOfMethod("bar()") == -1) - #self.assertTrue(o.metaObject().indexOfMethod("slot()") > -1) - - #slot_index = o.metaObject().indexOfMethod("slot()") - - #o.connect(o, SIGNAL("foo()"), o2, SIGNAL("bar()")) - #signal_index = o.metaObject().indexOfMethod("foo()"); - - #self.assertTrue(slot_index != signal_index) # PYSIDE-784, plain Qt objects should not have intermediary # metaObjects. @@ -95,7 +113,101 @@ class qmetaobject_test(unittest.TestCase): self.assertEqual(timer.metaObject().superClass().className(), "QObject") + # PYSIDE-1827, slots with non-QObject object types should work + # (metatypes are registered) + def test_ObjectSlotSignal(self): + app = QCoreApplication() # noqa: F841 + sender = SemaphoreSender() + receiver = SemaphoreReceiver() + sender.signal.connect(receiver.receiverSlot, Qt.QueuedConnection) + sender.emitSignal() + while not receiver.semaphore: + QCoreApplication.processEvents() + self.assertEqual(sender.semaphore, receiver.semaphore) + + # PYSIDE-1898, + def test_Invoke(self): + tester = InvokeTester() + + # Primitive types + sum = QMetaObject.invokeMethod(tester, "add", Q_RETURN_ARG(int), + Q_ARG(int, 2), Q_ARG(int, 3)) + self.assertEqual(sum, 5) + + # Same with QMetaMethod + mo = tester.metaObject() + method = mo.method(mo.indexOfMethod("add(int,int)")) + self.assertTrue(method.isValid()) + sum = method.invoke(tester, Qt.ConnectionType.AutoConnection, + Q_RETURN_ARG(int), Q_ARG(int, 2), Q_ARG(int, 3)) + self.assertEqual(sum, 5) + sum = method.invoke(tester, Q_RETURN_ARG(int), Q_ARG(int, 2), + Q_ARG(int, 3)) + self.assertEqual(sum, 5) + + concatenated = QMetaObject.invokeMethod(tester, "concatenate", + Q_RETURN_ARG(str), + Q_ARG(str, "bla"), + Q_ARG(str, "bla")) + self.assertEqual(concatenated, "blabla") + + # Wrapped type as in-parameter + point = QPoint(10, 20) + len = QMetaObject.invokeMethod(tester, "manhattan_length", + Q_RETURN_ARG(int), + Q_ARG(QPoint, point)) + self.assertEqual(len, point.manhattanLength()) + + # Wrapped type as result + point2 = QPoint(30, 30) + point3 = QMetaObject.invokeMethod(tester, "add_points", + Q_RETURN_ARG(QPoint), + Q_ARG(QPoint, point), + Q_ARG(QPoint, point2)) + self.assertEqual(point + point2, point3) + + # Pass an object + o = QObject() + o.setObjectName("Foo") + name = QMetaObject.invokeMethod(tester, "object_name", + Q_RETURN_ARG(str), + Q_ARG(QObject, o)) + self.assertEqual(name, o.objectName()) + + # Return an object + child = QObject(o) + child.setObjectName("Child") + c = QMetaObject.invokeMethod(tester, "first_child", + Q_RETURN_ARG(QObject), + Q_ARG(QObject, o)) + self.assertTrue(c) + self.assertEqual(c, child) + + def test_InvokeTypeString(self): + strings = ["item1", "item2"] + model = QStringListModel(strings) + index = model.index(1, 0) + QMetaObject.invokeMethod(model, "setData", + Q_ARG(QModelIndex, index), + Q_ARG("QVariant", "bla")) + self.assertEqual(model.data(index), "bla") + + # Same with QMetaMethod + mo = model.metaObject() + method = mo.method(mo.indexOfMethod("setData(QModelIndex,QVariant)")) + self.assertTrue(method.isValid()) + method.invoke(model, Qt.ConnectionType.AutoConnection, + Q_ARG(QModelIndex, index), Q_ARG("QVariant", "blub")) + self.assertEqual(model.data(index), "blub") + method.invoke(model, Q_ARG(QModelIndex, index), Q_ARG("QVariant", "blip")) + self.assertEqual(model.data(index), "blip") + + def test_QMetaMethod(self): + o = QObject() + m = QMetaMethod.fromSignal(o.destroyed) + self.assertTrue(m.isValid) + self.assertEqual(m.methodSignature(), b"destroyed()") + if __name__ == '__main__': unittest.main() - diff --git a/sources/pyside6/tests/QtCore/qmetatype_test.py b/sources/pyside6/tests/QtCore/qmetatype_test.py new file mode 100644 index 000000000..f8e0ba1c0 --- /dev/null +++ b/sources/pyside6/tests/QtCore/qmetatype_test.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# Copyright (C) 2022The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Tests for QMetaType''' + +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) + +from PySide6.QtCore import (QMetaType, QObject, QPoint) + + +class qmetatype_test(unittest.TestCase): + def test_ObjectSlotSignal(self): + meta_type = QMetaType(int) + self.assertTrue(meta_type.isValid()) + self.assertEqual(meta_type.name(), "int") + + meta_type = QMetaType(str) + self.assertTrue(meta_type.isValid()) + self.assertEqual(meta_type.name(), "QString") + + meta_type = QMetaType(float) + self.assertTrue(meta_type.isValid()) + self.assertEqual(meta_type.name(), "double") + + meta_type = QMetaType(QPoint) + self.assertTrue(meta_type.isValid()) + self.assertEqual(meta_type.name(), "QPoint") + + meta_type = QMetaType(QObject) + self.assertTrue(meta_type.isValid()) + self.assertEqual(meta_type.name(), "QObject*") + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/qmimedatabase_test.py b/sources/pyside6/tests/QtCore/qmimedatabase_test.py index 099f9e10e..6a63edb85 100644 --- a/sources/pyside6/tests/QtCore/qmimedatabase_test.py +++ b/sources/pyside6/tests/QtCore/qmimedatabase_test.py @@ -1,36 +1,9 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QMimeDatabase''' -import ctypes import os import sys import unittest @@ -50,8 +23,7 @@ class QMimeDatabaseTest(unittest.TestCase): s0 = db.mimeTypeForName("application/x-zerosize") self.assertTrue(s0.isValid()) self.assertEqual(s0.name(), "application/x-zerosize") - if "en" in QLocale().name(): - self.assertEqual(s0.comment(), "empty document") + self.assertTrue(s0.comment()) s0Again = db.mimeTypeForName("application/x-zerosize") self.assertEqual(s0Again.name(), s0.name()) @@ -66,13 +38,13 @@ class QMimeDatabaseTest(unittest.TestCase): rdf = db.mimeTypeForName("application/rdf+xml") self.assertTrue(rdf.isValid()) self.assertEqual(rdf.name(), "application/rdf+xml") + self.assertTrue(rdf.comment()) if "en" in QLocale().name(): self.assertEqual(rdf.comment(), "RDF file") bzip2 = db.mimeTypeForName("application/x-bzip2") self.assertTrue(bzip2.isValid()) - if "en" in QLocale().name(): - self.assertEqual(bzip2.comment(), "Bzip archive") + self.assertTrue(bzip2.comment()) defaultMime = db.mimeTypeForName("application/octet-stream") self.assertTrue(defaultMime.isValid()) diff --git a/sources/pyside6/tests/QtCore/qmodelindex_internalpointer_test.py b/sources/pyside6/tests/QtCore/qmodelindex_internalpointer_test.py index 70ca5b9a6..ec37ca6a0 100644 --- a/sources/pyside6/tests/QtCore/qmodelindex_internalpointer_test.py +++ b/sources/pyside6/tests/QtCore/qmodelindex_internalpointer_test.py @@ -1,35 +1,9 @@ -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer''' +import gc import os import sys import unittest @@ -56,6 +30,8 @@ class TestQModelIndexInternalPointer(unittest.TestCase): def tearDown(self): # Release resources del self.model + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testInternalPointer(self): # Test QAbstractListModel.createIndex and @@ -65,6 +41,7 @@ class TestQModelIndexInternalPointer(unittest.TestCase): i = idx.internalPointer() self.assertEqual(i, "Hello") + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testReferenceCounting(self): # Test reference counting when retrieving data with # QModelIndex.internalPointer diff --git a/sources/pyside6/tests/QtCore/qobject_children_segfault_test.py b/sources/pyside6/tests/QtCore/qobject_children_segfault_test.py index cab045ddc..508526cca 100644 --- a/sources/pyside6/tests/QtCore/qobject_children_segfault_test.py +++ b/sources/pyside6/tests/QtCore/qobject_children_segfault_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for parent-child relationship''' +import gc import os import sys import unittest @@ -57,6 +33,8 @@ class ChildrenCoreApplication(unittest.TestCase): # del children # del child2 del parent # XXX Segfaults here + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertTrue(True) diff --git a/sources/pyside6/tests/QtCore/qobject_connect_notify_test.py b/sources/pyside6/tests/QtCore/qobject_connect_notify_test.py index a5b44a2a1..b3bfaf007 100644 --- a/sources/pyside6/tests/QtCore/qobject_connect_notify_test.py +++ b/sources/pyside6/tests/QtCore/qobject_connect_notify_test.py @@ -1,32 +1,5 @@ -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' Test case for QObject::connectNotify()''' @@ -39,8 +12,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QObject, SIGNAL, SLOT -from helper.usesqcoreapplication import UsesQCoreApplication +from PySide6.QtCore import QObject, Signal, SIGNAL, SLOT +from helper.usesqapplication import UsesQApplication def cute_slot(): @@ -48,6 +21,9 @@ def cute_slot(): class Obj(QObject): + + foo = Signal() + def __init__(self): super().__init__() self.con_notified = False @@ -66,49 +42,56 @@ class Obj(QObject): self.dis_notified = False -class TestQObjectConnectNotify(UsesQCoreApplication): +class TestQObjectConnectNotify(UsesQApplication): '''Test case for QObject::connectNotify''' def setUp(self): - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) self.called = False def tearDown(self): - UsesQCoreApplication.tearDown(self) + UsesQApplication.tearDown(self) def testBasic(self): sender = Obj() receiver = QObject() + sender.destroyed.connect(receiver.deleteLater) + self.assertTrue(sender.con_notified) + self.assertEqual(sender.signal.methodSignature(), "destroyed()") + self.assertTrue(sender.destroyed.disconnect(receiver.deleteLater)) + self.assertTrue(sender.dis_notified) + + def testBasicString(self): + sender = Obj() + receiver = QObject() sender.connect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) self.assertTrue(sender.con_notified) # When connecting to a regular slot, and not a python callback function, QObject::connect # will use the non-cloned method signature, so connecting to destroyed() will actually # connect to destroyed(QObject*). self.assertEqual(sender.signal.methodSignature(), "destroyed(QObject*)") - sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) + self.assertTrue(sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()"))) self.assertTrue(sender.dis_notified) def testPySignal(self): sender = Obj() receiver = QObject() - sender.connect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) + sender.foo.connect(receiver.deleteLater) self.assertTrue(sender.con_notified) - sender.disconnect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) + self.assertTrue(sender.foo.disconnect(receiver.deleteLater)) self.assertTrue(sender.dis_notified) def testPySlots(self): sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("destroyed()"), cute_slot) + sender.destroyed.connect(cute_slot) self.assertTrue(sender.con_notified) - sender.disconnect(SIGNAL("destroyed()"), cute_slot) + self.assertTrue(sender.destroyed.disconnect(cute_slot)) self.assertTrue(sender.dis_notified) def testpyAll(self): sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("foo()"), cute_slot) + sender.foo.connect(cute_slot) self.assertTrue(sender.con_notified) - sender.disconnect(SIGNAL("foo()"), cute_slot) + self.assertTrue(sender.foo.disconnect(cute_slot)) self.assertTrue(sender.dis_notified) diff --git a/sources/pyside6/tests/QtCore/qobject_destructor.py b/sources/pyside6/tests/QtCore/qobject_destructor.py index d24017397..2b7b40f25 100644 --- a/sources/pyside6/tests/QtCore/qobject_destructor.py +++ b/sources/pyside6/tests/QtCore/qobject_destructor.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -45,6 +20,7 @@ class MyObject(QObject): class TestDestructor(unittest.TestCase): + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testReference(self): o = QObject() m = MyObject(o) diff --git a/sources/pyside6/tests/QtCore/qobject_event_filter_test.py b/sources/pyside6/tests/QtCore/qobject_event_filter_test.py index 362982000..ab7a1b6ad 100644 --- a/sources/pyside6/tests/QtCore/qobject_event_filter_test.py +++ b/sources/pyside6/tests/QtCore/qobject_event_filter_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QObject.eventFilter''' +import gc import os import sys import unittest @@ -40,7 +16,7 @@ init_test_paths(False) from PySide6.QtCore import QObject, QTimerEvent -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication class FilterObject(QObject): @@ -87,20 +63,33 @@ class FilteredObject(QObject): self.app.quit() -class TestQObjectEventFilterPython(UsesQCoreApplication): +class PolymorphicIdFilterObject(QObject): + """PYSIDE-2675: Check whether QChildEvent.added() is accessible via PolymorphicId""" + def __init__(self, parent=None): + super().__init__(parent) + self.added = False + + def event(self, event): + self.added = event.added() + return False + + +class TestQObjectEventFilterPython(UsesQApplication): '''QObject.eventFilter - Reimplemented in python Filters 5 TimerEvents and then bypasses the other events to the timerEvent method. After 5 runs, the timerEvent method will ask the core application to exit''' def setUp(self): # Acquire resources - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) self.obj_filter = FilterObject(event_type=QTimerEvent) def tearDown(self): # Release resources del self.obj_filter - UsesQCoreApplication.tearDown(self) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + UsesQApplication.tearDown(self) def testEventFilter(self): # QObject.eventFilter reimplemented in python @@ -115,6 +104,12 @@ class TestQObjectEventFilterPython(UsesQCoreApplication): self.assertEqual(filtered.times_called, 5) self.assertEqual(self.obj_filter.events_handled, 5) + def testPolymorphicId(self): + testObject = PolymorphicIdFilterObject() + t2 = QObject(testObject) # noqa: F841 + self.assertTrue(testObject.added) + + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testInstallEventFilterRefCountAfterDelete(self): '''Bug 910 - installEventFilter() increments reference count on target object http://bugs.pyside.org/show_bug.cgi?id=910''' @@ -131,6 +126,7 @@ class TestQObjectEventFilterPython(UsesQCoreApplication): del obj self.assertEqual(wref(), None) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testInstallEventFilterRefCountAfterRemove(self): # Bug 910 obj = QObject() diff --git a/sources/pyside6/tests/QtCore/qobject_inherits_test.py b/sources/pyside6/tests/QtCore/qobject_inherits_test.py index e2577fd40..0bd4fba75 100644 --- a/sources/pyside6/tests/QtCore/qobject_inherits_test.py +++ b/sources/pyside6/tests/QtCore/qobject_inherits_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QObject methods''' +import gc import os import sys import unittest @@ -125,9 +101,13 @@ class InheritsCase(unittest.TestCase): child.deleteLater() self.assertTrue(is_alive) del child + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertTrue(is_alive) QTimer.singleShot(100, app.quit) app.exec() + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertFalse(is_alive) diff --git a/sources/pyside6/tests/QtCore/qobject_objectproperty_test.py b/sources/pyside6/tests/QtCore/qobject_objectproperty_test.py index 9143355f2..f1a4cb0b5 100644 --- a/sources/pyside6/tests/QtCore/qobject_objectproperty_test.py +++ b/sources/pyside6/tests/QtCore/qobject_objectproperty_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test case for the bug #378 http://bugs.openbossa.org/show_bug.cgi?id=378 diff --git a/sources/pyside6/tests/QtCore/qobject_parent_test.py b/sources/pyside6/tests/QtCore/qobject_parent_test.py index 63f8e3561..6265f77b1 100644 --- a/sources/pyside6/tests/QtCore/qobject_parent_test.py +++ b/sources/pyside6/tests/QtCore/qobject_parent_test.py @@ -1,36 +1,11 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for parent-child relationship''' +import gc import os import sys -from sys import getrefcount import unittest from pathlib import Path @@ -63,24 +38,29 @@ class ParentRefCountCase(unittest.TestCase): # Release resources del self.child del self.parent + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testSetParent(self): # QObject.setParent() refcount changes - self.assertEqual(getrefcount(self.child), 2) + self.assertEqual(sys.getrefcount(self.child), 2) self.child.setParent(self.parent) - self.assertEqual(getrefcount(self.child), 3) + self.assertEqual(sys.getrefcount(self.child), 3) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testSetParentTwice(self): - self.assertEqual(getrefcount(self.child), 2) + self.assertEqual(sys.getrefcount(self.child), 2) self.child.setParent(self.parent) - self.assertEqual(getrefcount(self.child), 3) + self.assertEqual(sys.getrefcount(self.child), 3) self.child.setParent(self.parent) - self.assertEqual(getrefcount(self.child), 3) + self.assertEqual(sys.getrefcount(self.child), 3) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testConstructor(self): # QObject(QObject) refcount changes child = QObject(self.parent) - self.assertEqual(getrefcount(child), 3) + self.assertEqual(sys.getrefcount(child), 3) class ParentCase(unittest.TestCase): @@ -103,6 +83,8 @@ class ParentCase(unittest.TestCase): orig_repr = repr(child) del child + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertEqual(orig_repr, repr(parent.children()[0])) def testChildren(self): @@ -123,10 +105,9 @@ class ParentCase(unittest.TestCase): for i, child in enumerate(children): self.assertEqual(child, parent.findChild(QObject, f'object{i}')) - def testFindChildOptions(self): parent = QObject() - child = QObject(parent) + child = QObject(parent) nested_child_name = 'nestedChild' nested_child = QObject(child) nested_child.setObjectName(nested_child_name) @@ -215,77 +196,81 @@ class ParentCase(unittest.TestCase): class TestParentOwnership(unittest.TestCase): '''Test case for Parent/Child object ownership''' + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testParentDestructor(self): parent = QObject() - self.assertEqual(getrefcount(parent), 2) + self.assertEqual(sys.getrefcount(parent), 2) child = QObject(parent) - self.assertEqual(getrefcount(child), 3) - self.assertEqual(getrefcount(parent), 2) + self.assertEqual(sys.getrefcount(child), 3) + self.assertEqual(sys.getrefcount(parent), 2) del parent - self.assertEqual(getrefcount(child), 2) + self.assertEqual(sys.getrefcount(child), 2) # this will fail because parent deleted child cpp object self.assertRaises(RuntimeError, lambda: child.objectName()) # test parent with multiples children + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testMultipleChildren(self): o = QObject() - self.assertEqual(getrefcount(o), 2) + self.assertEqual(sys.getrefcount(o), 2) c = QObject(o) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(o), 2) + self.assertEqual(sys.getrefcount(c), 3) + self.assertEqual(sys.getrefcount(o), 2) c2 = QObject(o) - self.assertEqual(getrefcount(o), 2) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(c2), 3) + self.assertEqual(sys.getrefcount(o), 2) + self.assertEqual(sys.getrefcount(c), 3) + self.assertEqual(sys.getrefcount(c2), 3) del o - self.assertEqual(getrefcount(c), 2) - self.assertEqual(getrefcount(c2), 2) + self.assertEqual(sys.getrefcount(c), 2) + self.assertEqual(sys.getrefcount(c2), 2) # this will fail because parent deleted child cpp object self.assertRaises(RuntimeError, lambda: c.objectName()) self.assertRaises(RuntimeError, lambda: c2.objectName()) # test recursive parent + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testRecursiveParent(self): o = QObject() - self.assertEqual(getrefcount(o), 2) + self.assertEqual(sys.getrefcount(o), 2) c = QObject(o) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(o), 2) + self.assertEqual(sys.getrefcount(c), 3) + self.assertEqual(sys.getrefcount(o), 2) c2 = QObject(c) - self.assertEqual(getrefcount(o), 2) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(c2), 3) + self.assertEqual(sys.getrefcount(o), 2) + self.assertEqual(sys.getrefcount(c), 3) + self.assertEqual(sys.getrefcount(c2), 3) del o - self.assertEqual(getrefcount(c), 2) - self.assertEqual(getrefcount(c2), 2) + self.assertEqual(sys.getrefcount(c), 2) + self.assertEqual(sys.getrefcount(c2), 2) # this will fail because parent deleted child cpp object self.assertRaises(RuntimeError, lambda: c.objectName()) self.assertRaises(RuntimeError, lambda: c2.objectName()) # test parent transfer + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testParentTransfer(self): o = QObject() - self.assertEqual(getrefcount(o), 2) + self.assertEqual(sys.getrefcount(o), 2) c = QObject() - self.assertEqual(getrefcount(c), 2) + self.assertEqual(sys.getrefcount(c), 2) c.setParent(o) - self.assertEqual(getrefcount(c), 3) + self.assertEqual(sys.getrefcount(c), 3) c.setParent(None) - self.assertEqual(getrefcount(c), 2) + self.assertEqual(sys.getrefcount(c), 2) del c del o diff --git a/sources/pyside6/tests/QtCore/qobject_property_test.py b/sources/pyside6/tests/QtCore/qobject_property_test.py index d141a97df..4efb25cb4 100644 --- a/sources/pyside6/tests/QtCore/qobject_property_test.py +++ b/sources/pyside6/tests/QtCore/qobject_property_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QObject property and setProperty''' diff --git a/sources/pyside6/tests/QtCore/qobject_protected_methods_test.py b/sources/pyside6/tests/QtCore/qobject_protected_methods_test.py index 9b89abf9c..926698b4b 100644 --- a/sources/pyside6/tests/QtCore/qobject_protected_methods_test.py +++ b/sources/pyside6/tests/QtCore/qobject_protected_methods_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QObject protected methods''' diff --git a/sources/pyside6/tests/QtCore/qobject_test.py b/sources/pyside6/tests/QtCore/qobject_test.py index b399b84c9..ecfc3dff0 100644 --- a/sources/pyside6/tests/QtCore/qobject_test.py +++ b/sources/pyside6/tests/QtCore/qobject_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QObject methods''' diff --git a/sources/pyside6/tests/QtCore/qobject_timer_event_test.py b/sources/pyside6/tests/QtCore/qobject_timer_event_test.py index f6fc2e080..9e657c27f 100644 --- a/sources/pyside6/tests/QtCore/qobject_timer_event_test.py +++ b/sources/pyside6/tests/QtCore/qobject_timer_event_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test case for QObject.timerEvent overloading''' @@ -41,7 +15,7 @@ init_test_paths(False) from PySide6.QtCore import QObject, QCoreApplication -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication class Dummy(QObject): @@ -60,7 +34,7 @@ class Dummy(QObject): self.app.exit(0) -class QObjectTimerEvent(UsesQCoreApplication): +class QObjectTimerEvent(UsesQApplication): def setUp(self): # Acquire resources diff --git a/sources/pyside6/tests/QtCore/qobject_tr_as_instance_test.py b/sources/pyside6/tests/QtCore/qobject_tr_as_instance_test.py index f70c04344..9123c5155 100644 --- a/sources/pyside6/tests/QtCore/qobject_tr_as_instance_test.py +++ b/sources/pyside6/tests/QtCore/qobject_tr_as_instance_test.py @@ -1,36 +1,10 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QObject's tr static methods.''' +import gc import os import os import sys @@ -43,7 +17,7 @@ init_test_paths(False) from PySide6.QtCore import QObject -#from helper.usesqcoreapplication import UsesQCoreApplication +#from helper.usesqapplication import UsesQApplication class QObjectTrTest(unittest.TestCase): @@ -54,6 +28,8 @@ class QObjectTrTest(unittest.TestCase): def tearDown(self): del self.obj + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testTrCommonCase(self): # Test common case for QObject.tr diff --git a/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py b/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py index e7c784300..d887029ac 100644 --- a/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py +++ b/sources/pyside6/tests/QtCore/qoperatingsystemversion_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qpoint_test.py b/sources/pyside6/tests/QtCore/qpoint_test.py index a2a92d3ef..b9d5afa37 100644 --- a/sources/pyside6/tests/QtCore/qpoint_test.py +++ b/sources/pyside6/tests/QtCore/qpoint_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QPoint and QPointF''' diff --git a/sources/pyside6/tests/QtCore/qprocess_test.py b/sources/pyside6/tests/QtCore/qprocess_test.py index 9634f26d3..ba4d29102 100644 --- a/sources/pyside6/tests/QtCore/qprocess_test.py +++ b/sources/pyside6/tests/QtCore/qprocess_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QProcess''' diff --git a/sources/pyside6/tests/QtCore/qproperty_decorator.py b/sources/pyside6/tests/QtCore/qproperty_decorator.py index 424b9dc9a..19f2bd251 100644 --- a/sources/pyside6/tests/QtCore/qproperty_decorator.py +++ b/sources/pyside6/tests/QtCore/qproperty_decorator.py @@ -1,31 +1,7 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +import gc import os import sys import unittest @@ -67,6 +43,10 @@ class PropertyTest(unittest.TestCase): self.assertEqual(o._value, 10) self.assertEqual(o.value, 10) del o + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + # PYSIDE-535: Why do I need to do it twice, here? + gc.collect() self.assertTrue(self._obDestroyed) diff --git a/sources/pyside6/tests/QtCore/qrandomgenerator_test.py b/sources/pyside6/tests/QtCore/qrandomgenerator_test.py index 36d2a0e03..c13a8b24a 100644 --- a/sources/pyside6/tests/QtCore/qrandomgenerator_test.py +++ b/sources/pyside6/tests/QtCore/qrandomgenerator_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qrect_test.py b/sources/pyside6/tests/QtCore/qrect_test.py index 83c3618d5..8a14abc5a 100644 --- a/sources/pyside6/tests/QtCore/qrect_test.py +++ b/sources/pyside6/tests/QtCore/qrect_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QRect''' diff --git a/sources/pyside6/tests/QtCore/qregularexpression_test.py b/sources/pyside6/tests/QtCore/qregularexpression_test.py index 20b582259..a88c2dc24 100644 --- a/sources/pyside6/tests/QtCore/qregularexpression_test.py +++ b/sources/pyside6/tests/QtCore/qregularexpression_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QRegularExpression''' diff --git a/sources/pyside6/tests/QtCore/qresource_test.py b/sources/pyside6/tests/QtCore/qresource_test.py index a9bdbfe51..1cdd2c785 100644 --- a/sources/pyside6/tests/QtCore/qresource_test.py +++ b/sources/pyside6/tests/QtCore/qresource_test.py @@ -1,32 +1,5 @@ -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QResource usage''' @@ -58,7 +31,7 @@ class ResourcesUsage(unittest.TestCase): if carriage_return != -1: orig.remove(carriage_return, 1) - f = QFile(':/quote.txt') #|QIODevice.Text + f = QFile(':/quote.txt') # |QIODevice.Text self.assertTrue(f.open(QIODevice.ReadOnly), f.errorString()) copy = f.readAll() f.close() diff --git a/sources/pyside6/tests/QtCore/qrunnable_test.py b/sources/pyside6/tests/QtCore/qrunnable_test.py new file mode 100644 index 000000000..d52f50ce1 --- /dev/null +++ b/sources/pyside6/tests/QtCore/qrunnable_test.py @@ -0,0 +1,45 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Test cases for QRunnable''' + +import os +import sys +import unittest +from io import StringIO + +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) + +from PySide6.QtCore import QCoreApplication, QRunnable, QThreadPool, QThread, qDebug +from helper.usesqapplication import UsesQApplication +test_result = "" + + +def check_test(): + global test_result + test_result = "test works" + + +class QRunnableTest(UsesQApplication): + def testCreateWithAutoDelete(self): + global test_result + test_result = "" # reset + runnable = QRunnable.create(check_test) + runnable.run() + self.assertEqual(test_result, "test works") + + def testwithQThreadPool(self): + global test_result + test_result = "" # reset + runnable = QRunnable.create(check_test) + tp = QThreadPool.globalInstance() + tp.start(runnable) + self.assertTrue(tp.waitForDone()) + self.assertEqual(test_result, "test works") + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/qsettings_test.py b/sources/pyside6/tests/QtCore/qsettings_test.py index 72f3c3f00..64ceffd70 100644 --- a/sources/pyside6/tests/QtCore/qsettings_test.py +++ b/sources/pyside6/tests/QtCore/qsettings_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2019 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QDate''' +import gc import os import sys import unittest @@ -75,11 +51,17 @@ class TestQSettings(unittest.TestCase): self.assertTrue(dir.isValid()) file_name = dir.filePath('foo.ini') settings = QSettings(file_name, QSettings.IniFormat) + sample_list = ["a", "b"] + string_list_of_empty = [""] settings.setValue('zero_value', 0) settings.setValue('empty_list', []) + settings.setValue('some_strings', sample_list) + settings.setValue('string_list_of_empty', string_list_of_empty) settings.setValue('bool1', False) settings.setValue('bool2', True) del settings + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() # Loading values already set settings = QSettings(file_name, QSettings.IniFormat) @@ -88,6 +70,10 @@ class TestQSettings(unittest.TestCase): r = settings.value("variable") self.assertEqual(type(r), type(None)) + r = settings.value("variable", type=list) + self.assertEqual(type(r), list) + self.assertEqual(len(r), 0) + # Handling zero value r = settings.value('zero_value') self.assertEqual(type(r), int) @@ -104,6 +90,15 @@ class TestQSettings(unittest.TestCase): self.assertTrue(len(r) == 0) self.assertEqual(type(r), list) + r = settings.value('some_strings') + self.assertEqual(r, sample_list) + + r = settings.value('some_strings', type=list) + self.assertEqual(r, sample_list) + + r = settings.value('string_list_of_empty', type=list) + self.assertEqual(r, string_list_of_empty) + # Booleans r = settings.value('bool1') self.assertEqual(type(r), bool) diff --git a/sources/pyside6/tests/QtCore/qsharedmemory_client.py b/sources/pyside6/tests/QtCore/qsharedmemory_client.py index fd994b0cb..d16c36da9 100644 --- a/sources/pyside6/tests/QtCore/qsharedmemory_client.py +++ b/sources/pyside6/tests/QtCore/qsharedmemory_client.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Client for the unit test of QSharedMemory''' diff --git a/sources/pyside6/tests/QtCore/qsharedmemory_test.py b/sources/pyside6/tests/QtCore/qsharedmemory_test.py index ee2e6c40a..ed8a47939 100644 --- a/sources/pyside6/tests/QtCore/qsharedmemory_test.py +++ b/sources/pyside6/tests/QtCore/qsharedmemory_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QSharedMemory''' diff --git a/sources/pyside6/tests/QtCore/qsize_test.py b/sources/pyside6/tests/QtCore/qsize_test.py index 95705f51c..bc324ba73 100644 --- a/sources/pyside6/tests/QtCore/qsize_test.py +++ b/sources/pyside6/tests/QtCore/qsize_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QSize''' diff --git a/sources/pyside6/tests/QtCore/qslot_object_test.py b/sources/pyside6/tests/QtCore/qslot_object_test.py index 36368ae3d..a95afb090 100644 --- a/sources/pyside6/tests/QtCore/qslot_object_test.py +++ b/sources/pyside6/tests/QtCore/qslot_object_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -37,7 +11,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QCoreApplication, QObject, QTimer, SIGNAL, SLOT +from PySide6.QtCore import QCoreApplication, QObject, QTimer """ This is a simple slot test that was updated to use the qApp "macro". @@ -54,24 +28,23 @@ class objTest(QObject): def slot(self): self.ok = True - qApp.quit() + qApp.quit() # noqa: F821 class slotTest(unittest.TestCase): def quit_app(self): - qApp.quit() + qApp.quit() # noqa: F821 def testBasic(self): timer = QTimer() timer.setInterval(100) my_obj = objTest() - my_slot = SLOT("slot()") - QObject.connect(timer, SIGNAL("timeout()"), my_obj, my_slot) + timer.timeout.connect(my_obj.slot) timer.start(100) QTimer.singleShot(1000, self.quit_app) - qApp.exec() + qApp.exec() # noqa: F821 self.assertTrue(my_obj.ok) diff --git a/sources/pyside6/tests/QtCore/qsocketnotifier_test.py b/sources/pyside6/tests/QtCore/qsocketnotifier_test.py index b348d5aa7..2e812947c 100644 --- a/sources/pyside6/tests/QtCore/qsocketnotifier_test.py +++ b/sources/pyside6/tests/QtCore/qsocketnotifier_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QUuid''' @@ -40,13 +14,12 @@ 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 QApplication -from PySide6.QtCore import QSocketNotifier +from PySide6.QtCore import QCoreApplication, QSocketNotifier class QSocketNotifierTest(unittest.TestCase): def testClass(self): - app = QApplication([]) + app = QCoreApplication([]) # socketpair is not available on Windows if os.name != "nt": w_sock, r_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) diff --git a/sources/pyside6/tests/QtCore/qsrand_test.py b/sources/pyside6/tests/QtCore/qsrand_test.py index 4208ab951..fef44261b 100644 --- a/sources/pyside6/tests/QtCore/qsrand_test.py +++ b/sources/pyside6/tests/QtCore/qsrand_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import gc import os @@ -42,6 +17,11 @@ from PySide6.QtCore import QRandomGenerator class OverflowExceptionCollect(unittest.TestCase): '''Test case for OverflowError exception during garbage collection. See bug #147''' + def assertRaises(self, *args, **kwds): + if not hasattr(sys, "pypy_version_info"): + # PYSIDE-535: PyPy complains "Fatal RPython error: NotImplementedError" + return super().assertRaises(*args, **kwds) + def testOverflow(self): # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError self.assertRaises(OverflowError, QRandomGenerator, 42415335332353253) diff --git a/sources/pyside6/tests/QtCore/qstandardpaths_test.py b/sources/pyside6/tests/QtCore/qstandardpaths_test.py index 070942474..b8274769b 100644 --- a/sources/pyside6/tests/QtCore/qstandardpaths_test.py +++ b/sources/pyside6/tests/QtCore/qstandardpaths_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QStandardPaths''' diff --git a/sources/pyside6/tests/QtCore/qstorageinfo_test.py b/sources/pyside6/tests/QtCore/qstorageinfo_test.py index 35413f081..5869d9f00 100644 --- a/sources/pyside6/tests/QtCore/qstorageinfo_test.py +++ b/sources/pyside6/tests/QtCore/qstorageinfo_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QStorageInfo''' diff --git a/sources/pyside6/tests/QtCore/qstring_test.py b/sources/pyside6/tests/QtCore/qstring_test.py index a43b2b94a..d740eeeef 100644 --- a/sources/pyside6/tests/QtCore/qstring_test.py +++ b/sources/pyside6/tests/QtCore/qstring_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QString''' @@ -52,6 +25,10 @@ class QStringConstructor(unittest.TestCase): self.assertEqual(obj.objectName(), 'foo') obj.setObjectName('áâãà ') self.assertEqual(obj.objectName(), 'áâãà ') + obj.setObjectName('A\x00B') + self.assertEqual(obj.objectName(), 'A\x00B') + obj.setObjectName('ä\x00B') + self.assertEqual(obj.objectName(), 'ä\x00B') obj.setObjectName(None) self.assertEqual(obj.objectName(), '') diff --git a/sources/pyside6/tests/QtCore/qsysinfo_test.py b/sources/pyside6/tests/QtCore/qsysinfo_test.py index ebd0f82ee..602852fab 100644 --- a/sources/pyside6/tests/QtCore/qsysinfo_test.py +++ b/sources/pyside6/tests/QtCore/qsysinfo_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -39,13 +14,14 @@ from PySide6.QtCore import QSysInfo class TestQSysInfo(unittest.TestCase): + def testEnumEndian(self): - self.assertEqual(QSysInfo.BigEndian, 0) - self.assertEqual(QSysInfo.LittleEndian, 1) - self.assertTrue(QSysInfo.ByteOrder > -1) + self.assertEqual(QSysInfo.BigEndian.value, 0) + self.assertEqual(QSysInfo.LittleEndian.value, 1) + self.assertTrue(QSysInfo.ByteOrder.value > -1) def testEnumSizes(self): - self.assertTrue(QSysInfo.WordSize > 0) + self.assertTrue(QSysInfo.WordSize.value > 0) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/qtextstream_test.py b/sources/pyside6/tests/QtCore/qtextstream_test.py index 64be2b9a3..d4ed94e14 100644 --- a/sources/pyside6/tests/QtCore/qtextstream_test.py +++ b/sources/pyside6/tests/QtCore/qtextstream_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QTextStream''' diff --git a/sources/pyside6/tests/QtCore/qthread_prod_cons_test.py b/sources/pyside6/tests/QtCore/qthread_prod_cons_test.py index 27178361d..a179c936f 100644 --- a/sources/pyside6/tests/QtCore/qthread_prod_cons_test.py +++ b/sources/pyside6/tests/QtCore/qthread_prod_cons_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Producer-Consumer test/example with QThread''' +import gc import logging import os from random import random @@ -116,10 +91,8 @@ class ProducerConsumer(unittest.TestCase): def tearDown(self): # Destroy fixtures del self.app - - def finishCb(self): - # Quits the application - self.app.exit(0) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testProdCon(self): # QThread producer-consumer example @@ -127,16 +100,14 @@ class ProducerConsumer(unittest.TestCase): prod = Producer(bucket) cons = Consumer(bucket) + cons.finished.connect(QCoreApplication.quit) prod.start() cons.start() - prod.finished.connect(self.finishCb) - cons.finished.connect(self.finishCb) - self.app.exec() - prod.wait(50) - cons.wait(50) + self.assertTrue(prod.wait(1000)) + self.assertTrue(cons.wait(1000)) self.assertEqual(prod.production_list, cons.consumption_list) diff --git a/sources/pyside6/tests/QtCore/qthread_signal_test.py b/sources/pyside6/tests/QtCore/qthread_signal_test.py index 87bd85b73..4e312dcc8 100644 --- a/sources/pyside6/tests/QtCore/qthread_signal_test.py +++ b/sources/pyside6/tests/QtCore/qthread_signal_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for connecting signals between threads''' @@ -37,41 +12,40 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QThread, QObject, SIGNAL, QCoreApplication - -thread_run = False +from PySide6.QtCore import QThread, QTimer, QObject, Signal, Slot, QCoreApplication class Source(QObject): + source = Signal() + def __init__(self, *args): - QObject.__init__(self, *args) + super().__init__(*args) + @Slot() def emit_sig(self): - self.emit(SIGNAL('source()')) + self.source.emit() class Target(QObject): def __init__(self, *args): - QObject.__init__(self, *args) + super().__init__(*args) self.called = False + @Slot() def myslot(self): self.called = True class ThreadJustConnects(QThread): def __init__(self, source, *args): - QThread.__init__(self, *args) + super().__init__(*args) self.source = source self.target = Target() def run(self): - global thread_run - thread_run = True - QObject.connect(self.source, SIGNAL('source()'), self.target.myslot) - - while not self.target.called: - pass + self.source.source.connect(self.target.myslot) + self.source.source.connect(self.quit) + self.exec() class BasicConnection(unittest.TestCase): @@ -83,14 +57,10 @@ class BasicConnection(unittest.TestCase): source = Source() thread = ThreadJustConnects(source) - QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0)) + thread.finished.connect(QCoreApplication.quit) thread.start() - while not thread_run: - pass - - source.emit_sig() - + QTimer.singleShot(50, source.emit_sig) app.exec() thread.wait() diff --git a/sources/pyside6/tests/QtCore/qthread_test.py b/sources/pyside6/tests/QtCore/qthread_test.py index 13c92b6f7..4d26e0597 100644 --- a/sources/pyside6/tests/QtCore/qthread_test.py +++ b/sources/pyside6/tests/QtCore/qthread_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QThread''' @@ -39,12 +13,10 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QThread, QCoreApplication, QObject, SIGNAL, QMutex, QTimer +from PySide6.QtCore import QThread, QCoreApplication, QObject, QTimer, Slot from PySide6.QtCore import QEventLoop -from helper.usesqcoreapplication import UsesQCoreApplication - -mutex = QMutex() +from helper.usesqapplication import UsesQApplication class Dummy(QThread): @@ -56,20 +28,17 @@ class Dummy(QThread): def run(self): # Start-quit sequence self.qobj = QObject() - mutex.lock() self.called = True - mutex.unlock() -class QThreadSimpleCase(UsesQCoreApplication): +class QThreadSimpleCase(UsesQApplication): def setUp(self): - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) + self._started_called = False + self._finished_called = False self.called = False - def tearDown(self): - UsesQCoreApplication.tearDown(self) - def testThread(self): # Basic QThread test obj = Dummy() @@ -78,41 +47,37 @@ class QThreadSimpleCase(UsesQCoreApplication): self.assertTrue(obj.called) - def cb(self, *args): - self.called = True - # self.exit_app_cb() - + @Slot() def abort_application(self): if self._thread.isRunning(): + print("Warning: terminating thread", file=sys.stderr) self._thread.terminate() self.app.quit() - def testSignalFinished(self): - # QThread.finished() (signal) - obj = Dummy() - obj.finished.connect(self.cb) - mutex.lock() - obj.start() - mutex.unlock() - - self._thread = obj - QTimer.singleShot(1000, self.abort_application) - self.app.exec() + @Slot() + def finished(self): + self._finished_called = True - self.assertTrue(self.called) + @Slot() + def started(self): + self._started_called = True - def testSignalStarted(self): - # QThread.started() (signal) - obj = Dummy() - obj.started.connect(self.cb) - obj.start() + def testSignals(self): + # QThread.finished() (signal) + self._thread = Dummy() + self._thread.started.connect(self.started) + self._thread.finished.connect(self.finished) + self._thread.finished.connect(self.app.quit) - self._thread = obj + QTimer.singleShot(50, self._thread.start) QTimer.singleShot(1000, self.abort_application) + self.app.exec() + if self._thread.isRunning(): + self._thread.wait(100) - self.assertEqual(obj.qobj.thread(), obj) # test QObject.thread() method - self.assertTrue(self.called) + self.assertTrue(self._started_called) + self.assertTrue(self._finished_called) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtCore/qtimer_singleshot_test.py b/sources/pyside6/tests/QtCore/qtimer_singleshot_test.py index 7aa315e17..2ccaa300e 100644 --- a/sources/pyside6/tests/QtCore/qtimer_singleshot_test.py +++ b/sources/pyside6/tests/QtCore/qtimer_singleshot_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for QTimer.singleShot''' +import gc import os import sys import unittest @@ -39,8 +14,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QObject, QTimer, QCoreApplication, Signal -from helper.usesqcoreapplication import UsesQCoreApplication +from PySide6.QtCore import QObject, QThread, QTimer, Signal, Slot, SLOT +from helper.usesqapplication import UsesQApplication class WatchDog(QObject): @@ -57,23 +32,41 @@ class WatchDog(QObject): self.watched.exit_app_cb() -class TestSingleShot(UsesQCoreApplication): +class ThreadForContext(QThread): + def __init__(self): + super().__init__() + self.called = False + self.qthread = None + self.context = QObject() + + def run(self): + self.called = True + self.qthread = QThread.currentThread() + self.exec() + + +class TestSingleShot(UsesQApplication): '''Test case for QTimer.singleShot''' def setUp(self): # Acquire resources - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) self.watchdog = WatchDog(self) self.called = False + self.qthread = None def tearDown(self): # Release resources del self.watchdog del self.called - UsesQCoreApplication.tearDown(self) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + UsesQApplication.tearDown(self) def callback(self): self.called = True + self.qthread = QThread.currentThread() + self.qthread.exit() self.app.quit() def testSingleShot(self): @@ -81,24 +74,103 @@ class TestSingleShot(UsesQCoreApplication): self.app.exec() self.assertTrue(self.called) + def testSingleShotZero(self): + QTimer.singleShot(0, self.callback) + self.app.exec() + self.assertTrue(self.called) + + def testSingleShotWithContext(self): + thread = ThreadForContext() + thread.start() + thread.context.moveToThread(thread) + QTimer.singleShot(100, thread.context, self.callback) + self.app.exec() + thread.wait() + self.assertTrue(self.called) + self.assertTrue(thread.called) + self.assertEqual(self.qthread, thread.qthread) + + def testSingleShotWithContextZero(self): + thread = ThreadForContext() + thread.start() + thread.context.moveToThread(thread) + QTimer.singleShot(0, thread.context, self.callback) + self.app.exec() + thread.wait() + self.assertTrue(self.called) + self.assertTrue(thread.called) + self.assertEqual(self.qthread, thread.qthread) + + +class TestSingleShotCallableObject(UsesQApplication): + '''Test case for QTimer.singleShot with callable inside an object''' + + def setUp(self): + # Acquire resources + UsesQApplication.setUp(self) + self.watchdog = WatchDog(self) + + def tearDown(self): + # Release resources + del self.watchdog + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + UsesQApplication.tearDown(self) + + class CallbackObject(QObject): + def __init__(self, app) -> None: + super().__init__() + self.app = app + + @Slot() + def func(self): + self.called = True + self.app.quit() + + def testSingleShotWithObjectAndMember(self): + callback = self.CallbackObject(self.app) + QTimer.singleShot(100, callback, SLOT("func()")) + self.app.exec() + self.assertTrue(callback.called) + + def testSingleShotWithObjectAndMemberZero(self): + callback = self.CallbackObject(self.app) + QTimer.singleShot(0, callback, SLOT("func()")) + self.app.exec() + self.assertTrue(callback.called) + + def testSingleShotWithCallableInObject(self): + callback = self.CallbackObject(self.app) + QTimer.singleShot(100, callback.func) + self.app.exec() + self.assertTrue(callback.called) + + def testSingleShotWithCallableInObjectZero(self): + callback = self.CallbackObject(self.app) + QTimer.singleShot(0, callback.func) + self.app.exec() + self.assertTrue(callback.called) + class SigEmitter(QObject): sig1 = Signal() -class TestSingleShotSignal(UsesQCoreApplication): +class TestSingleShotSignal(UsesQApplication): '''Test case for QTimer.singleShot connecting to signals''' def setUp(self): - UsesQCoreApplication.setUp(self) + UsesQApplication.setUp(self) self.watchdog = WatchDog(self) self.called = False def tearDown(self): del self.watchdog del self.called - UsesQCoreApplication.tearDown(self) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + UsesQApplication.tearDown(self) def callback(self): self.called = True @@ -111,7 +183,13 @@ class TestSingleShotSignal(UsesQCoreApplication): self.app.exec() self.assertTrue(self.called) + def testSingleShotSignalZero(self): + emitter = SigEmitter() + emitter.sig1.connect(self.callback) + QTimer.singleShot(0, emitter.sig1) + self.app.exec() + self.assertTrue(self.called) + if __name__ == '__main__': unittest.main() - diff --git a/sources/pyside6/tests/QtCore/qtimer_timeout_test.py b/sources/pyside6/tests/QtCore/qtimer_timeout_test.py index ed2780c7a..70f151989 100644 --- a/sources/pyside6/tests/QtCore/qtimer_timeout_test.py +++ b/sources/pyside6/tests/QtCore/qtimer_timeout_test.py @@ -1,33 +1,9 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test case for timeout() signals from QTimer object.''' +import gc import os import sys import unittest @@ -38,7 +14,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QObject, QTimer, SIGNAL -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication class WatchDog(QObject): @@ -55,12 +31,12 @@ class WatchDog(QObject): self.watched.exit_app_cb() -class TestTimeoutSignal(UsesQCoreApplication): +class TestTimeoutSignal(UsesQApplication): '''Test case to check if the signals are really being caught''' def setUp(self): # Acquire resources - UsesQCoreApplication.setUp(self) + super().setUp() self.watchdog = WatchDog(self) self.timer = QTimer() self.called = False @@ -70,12 +46,15 @@ class TestTimeoutSignal(UsesQCoreApplication): del self.watchdog del self.timer del self.called - UsesQCoreApplication.tearDown(self) + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + super().tearDown() def callback(self, *args): # Default callback self.called = True + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testTimeoutSignal(self): # Test the QTimer timeout() signal refCount = sys.getrefcount(self.timer) diff --git a/sources/pyside6/tests/QtCore/qtimezone_test.py b/sources/pyside6/tests/QtCore/qtimezone_test.py index da96f90e7..ad953f1cc 100644 --- a/sources/pyside6/tests/QtCore/qtimezone_test.py +++ b/sources/pyside6/tests/QtCore/qtimezone_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/qtnamespace_test.py b/sources/pyside6/tests/QtCore/qtnamespace_test.py index 2f76ffcad..c08c727ec 100644 --- a/sources/pyside6/tests/QtCore/qtnamespace_test.py +++ b/sources/pyside6/tests/QtCore/qtnamespace_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test suite for QtCore.Qt namespace''' diff --git a/sources/pyside6/tests/QtCore/qurl_test.py b/sources/pyside6/tests/QtCore/qurl_test.py index 8e5d5caea..df16c74e0 100644 --- a/sources/pyside6/tests/QtCore/qurl_test.py +++ b/sources/pyside6/tests/QtCore/qurl_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test suite for QtCore.QUrl''' diff --git a/sources/pyside6/tests/QtCore/qurlquery_test.py b/sources/pyside6/tests/QtCore/qurlquery_test.py index 224f253ff..36eb29475 100644 --- a/sources/pyside6/tests/QtCore/qurlquery_test.py +++ b/sources/pyside6/tests/QtCore/qurlquery_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QUrlQuery''' diff --git a/sources/pyside6/tests/QtCore/quuid_test.py b/sources/pyside6/tests/QtCore/quuid_test.py index 1729eb146..45c6fc89d 100644 --- a/sources/pyside6/tests/QtCore/quuid_test.py +++ b/sources/pyside6/tests/QtCore/quuid_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QUuid''' diff --git a/sources/pyside6/tests/QtCore/qversionnumber_test.py b/sources/pyside6/tests/QtCore/qversionnumber_test.py index eb02573a3..23f6ba639 100644 --- a/sources/pyside6/tests/QtCore/qversionnumber_test.py +++ b/sources/pyside6/tests/QtCore/qversionnumber_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QVersionNumber''' diff --git a/sources/pyside6/tests/QtCore/repr_test.py b/sources/pyside6/tests/QtCore/repr_test.py index 8fdb65ef8..87cceaa82 100644 --- a/sources/pyside6/tests/QtCore/repr_test.py +++ b/sources/pyside6/tests/QtCore/repr_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/resources_mc.py b/sources/pyside6/tests/QtCore/resources_mc.py index acbc561bb..05766a22a 100644 --- a/sources/pyside6/tests/QtCore/resources_mc.py +++ b/sources/pyside6/tests/QtCore/resources_mc.py @@ -1,32 +1,5 @@ -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 # Resource object code # diff --git a/sources/pyside6/tests/QtCore/setprop_on_ctor_test.py b/sources/pyside6/tests/QtCore/setprop_on_ctor_test.py index 0cd56ac93..de8f67bb3 100644 --- a/sources/pyside6/tests/QtCore/setprop_on_ctor_test.py +++ b/sources/pyside6/tests/QtCore/setprop_on_ctor_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/signal_sender.py b/sources/pyside6/tests/QtCore/signal_sender.py new file mode 100644 index 000000000..2552591e5 --- /dev/null +++ b/sources/pyside6/tests/QtCore/signal_sender.py @@ -0,0 +1,91 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +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) + +from helper.usesqapplication import UsesQApplication + +from PySide6.QtCore import (QCoreApplication, QObject, QStringListModel, + QTimer, Signal, Slot, Qt) + + +class Sender(QObject): + testSignal = Signal() + + def emitSignal(self): + self.testSignal.emit() + + +class Receiver(QObject): + + def __init__(self, parent=None): + super().__init__() + self._sender = None + self._slot_count = 0 + + @Slot() + def testSlot(self): + self._sender = self.sender() + self._slot_count += 1 + + +class DerivedReceiver(Receiver): + pass + + +class TestSignalSender(UsesQApplication): + """Test PYSIDE-2144/1295, check that QObject::sender() works also if it is + routed via GlobalReceiverV2 in case of a non-C++ slot (Python callback, + as for derived classes).""" + def testSignalSender(self): + sender = Sender() + receiver = Receiver() + sender.testSignal.connect(receiver.testSlot) + derived_receiver = DerivedReceiver() + sender.testSignal.connect(derived_receiver.testSlot) + sender.emitSignal() + + QTimer.singleShot(100, self.app.quit) + while derived_receiver._slot_count == 0: + QCoreApplication.processEvents() + + self.assertEqual(receiver._sender, sender) + self.assertEqual(derived_receiver._sender, sender) + + +class TestConstructorConnection(UsesQApplication): + """PYSIDE-2329: Check constructor connections for signals from the + base as well as signals with arguments.""" + def testConstructorConnection(self): + + was_destroyed = False + was_changed = False + + def destroyed_handler(): + nonlocal was_destroyed + was_destroyed = True + + def changed_handler(): + nonlocal was_changed + was_changed = True + + data_list = ["blub"] + model = QStringListModel(data_list, + destroyed=destroyed_handler, + dataChanged=changed_handler) + model.setData(model.index(0, 0), "bla", Qt.EditRole) + del model + + self.assertTrue(was_changed) + self.assertTrue(was_destroyed) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py index 7925c4c0c..82087ab9a 100644 --- a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py +++ b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py @@ -1,41 +1,5 @@ -############################################################################# -## -## Copyright (C) 2020 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$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only import os import sys @@ -46,8 +10,12 @@ 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 QApplication, QWidget -from PySide6.support import __feature__ +from PySide6.QtCore import Property, QSize +from PySide6.QtWidgets import QApplication, QMainWindow, QWidget + +is_pypy = hasattr(sys, "pypy_version_info") +if not is_pypy: + from PySide6.support import feature """ snake_prop_feature_test.py @@ -64,13 +32,14 @@ class Window(QWidget): super().__init__() +@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy") class FeatureTest(unittest.TestCase): def setUp(self): qApp or QApplication() - __feature__.set_selection(0) + feature.reset() def tearDown(self): - __feature__.set_selection(0) + feature.reset() qApp.shutdown() def testRenamedFunctions(self): @@ -91,7 +60,7 @@ class FeatureTest(unittest.TestCase): window.modal from __feature__ import snake_case, true_property - #PYSIDE-1548: Make sure that another import does not clear the features. + # PYSIDE-1548: Make sure that another import does not clear the features. import sys self.assertTrue(isinstance(QWidget.modal, property)) @@ -100,7 +69,7 @@ class FeatureTest(unittest.TestCase): window.isModal # switching back - __feature__.set_selection(0) + feature.reset() self.assertTrue(callable(window.isModal)) with self.assertRaises(AttributeError): @@ -122,6 +91,53 @@ class FeatureTest(unittest.TestCase): self.assertEqual(qApp.quit_on_last_window_closed, QApplication.quit_on_last_window_closed) + def testUserClassNotAffected(self): + FunctionType = type(lambda: 42) + # Note: the types module does not have MethodDescriptorType in low versions. + MethodDescriptorType = type(str.split) + + class UserClass(QWidget): + + def someFunc1(self): + pass + + @staticmethod + def someFunc2(a, b): + pass + + inspect = UserClass.__dict__ + self.assertTrue(isinstance(inspect["someFunc1"], FunctionType)) + self.assertTrue(isinstance(inspect["someFunc2"], staticmethod)) + self.assertTrue(isinstance(UserClass.someFunc2, FunctionType)) + self.assertTrue(isinstance(UserClass.addAction, MethodDescriptorType)) + + from __feature__ import snake_case + + inspect = UserClass.__dict__ + self.assertTrue(isinstance(inspect["someFunc1"], FunctionType)) + self.assertTrue(isinstance(inspect["someFunc2"], staticmethod)) + self.assertTrue(isinstance(UserClass.someFunc2, FunctionType)) + self.assertTrue(isinstance(UserClass.add_action, MethodDescriptorType)) + + def testTrueProperyCanOverride(self): + from __feature__ import true_property + + class CustomWidget(QWidget): + global prop_result + prop_result = None + + @Property(QSize) + def minimumSizeHint(self): + global prop_result + print("called") + prop_result = super().minimumSizeHint + return prop_result + + window = QMainWindow() + window.setCentralWidget(CustomWidget(window)) + window.show() + self.assertTrue(isinstance(prop_result, QSize)) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtCore/staticMetaObject_test.py b/sources/pyside6/tests/QtCore/staticMetaObject_test.py index 77dbcd9fb..223c334d3 100644 --- a/sources/pyside6/tests/QtCore/staticMetaObject_test.py +++ b/sources/pyside6/tests/QtCore/staticMetaObject_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/sources/pyside6/tests/QtCore/static_method_test.py b/sources/pyside6/tests/QtCore/static_method_test.py index 5119f42a9..bbf96e44a 100644 --- a/sources/pyside6/tests/QtCore/static_method_test.py +++ b/sources/pyside6/tests/QtCore/static_method_test.py @@ -1,32 +1,6 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Test cases for overloads involving static and non-static versions of a method.''' diff --git a/sources/pyside6/tests/QtCore/thread_signals_test.py b/sources/pyside6/tests/QtCore/thread_signals_test.py index ffbde53b4..a453d1ac1 100644 --- a/sources/pyside6/tests/QtCore/thread_signals_test.py +++ b/sources/pyside6/tests/QtCore/thread_signals_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 ''' Test case for QObject.signalsBlocked() and blockSignal()''' @@ -37,17 +12,19 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt -from helper.usesqcoreapplication import UsesQCoreApplication +from PySide6.QtCore import Signal, QThread +from helper.usesqapplication import UsesQApplication class MyThread(QThread): + test = Signal(str) + def run(self): - self.emit(SIGNAL("test(const QString&)"), "INdT - PySide") + self.test.emit("INdT - PySide") -class TestThreadSignal(UsesQCoreApplication): +class TestThreadSignal(UsesQApplication): __called__ = True @@ -58,7 +35,7 @@ class TestThreadSignal(UsesQCoreApplication): def testThread(self): t = MyThread() - QObject.connect(t, SIGNAL("test(const QString&)"), self._callback) + t.test.connect(self._callback) t.start() self.app.exec() diff --git a/sources/pyside6/tests/QtCore/tr_noop_test.py b/sources/pyside6/tests/QtCore/tr_noop_test.py index b2139e754..a3b2e257f 100644 --- a/sources/pyside6/tests/QtCore/tr_noop_test.py +++ b/sources/pyside6/tests/QtCore/tr_noop_test.py @@ -1,31 +1,7 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +import gc import os import sys import unittest @@ -46,31 +22,38 @@ class QtTrNoopTest(unittest.TestCase): def tearDown(self): del self.txt + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testQtTrNoop(self): refcnt = sys.getrefcount(self.txt) result = QT_TR_NOOP(self.txt) self.assertEqual(result, self.txt) self.assertEqual(sys.getrefcount(result), refcnt + 1) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testQtTrNoopUtf8(self): refcnt = sys.getrefcount(self.txt) result = QT_TR_NOOP_UTF8(self.txt) self.assertEqual(result, self.txt) self.assertEqual(sys.getrefcount(result), refcnt + 1) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testQtTranslateNoop(self): refcnt = sys.getrefcount(self.txt) result = QT_TRANSLATE_NOOP(None, self.txt) self.assertEqual(result, self.txt) self.assertEqual(sys.getrefcount(result), refcnt + 1) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testQtTranslateNoopUtf8(self): refcnt = sys.getrefcount(self.txt) result = QT_TRANSLATE_NOOP_UTF8(self.txt) self.assertEqual(result, self.txt) self.assertEqual(sys.getrefcount(result), refcnt + 1) + @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testQtTranslateNoop3(self): refcnt = sys.getrefcount(self.txt) result = QT_TRANSLATE_NOOP3(None, self.txt, None) diff --git a/sources/pyside6/tests/QtCore/translation_test.py b/sources/pyside6/tests/QtCore/translation_test.py index beb707914..da09e47b6 100644 --- a/sources/pyside6/tests/QtCore/translation_test.py +++ b/sources/pyside6/tests/QtCore/translation_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests to test QTranslator and translation in general.''' @@ -42,10 +15,10 @@ init_test_paths(False) from PySide6.QtCore import QObject, QTranslator, QCoreApplication -from helper.usesqcoreapplication import UsesQCoreApplication +from helper.usesqapplication import UsesQApplication -class TranslationTest(UsesQCoreApplication): +class TranslationTest(UsesQApplication): '''Test case for Qt translation facilities.''' def setUp(self): diff --git a/sources/pyside6/tests/QtCore/unaryoperator_test.py b/sources/pyside6/tests/QtCore/unaryoperator_test.py index 614c92ee5..7b38685c8 100644 --- a/sources/pyside6/tests/QtCore/unaryoperator_test.py +++ b/sources/pyside6/tests/QtCore/unaryoperator_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Tests the presence of unary operator __neg__ on the QPoint class''' +import gc import os import sys import unittest @@ -58,6 +33,8 @@ class NegUnaryOperatorTest(unittest.TestCase): del self.y del self.neg_x del self.neg_y + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testNegUnaryOperator(self): # Test __neg__ unary operator on QPoint class diff --git a/sources/pyside6/tests/QtCore/unicode_test.py b/sources/pyside6/tests/QtCore/unicode_test.py index 18910be29..73ce96c77 100644 --- a/sources/pyside6/tests/QtCore/unicode_test.py +++ b/sources/pyside6/tests/QtCore/unicode_test.py @@ -1,33 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Unit tests for QString conversion to/from Python Unicode''' diff --git a/sources/pyside6/tests/QtCore/versioninfo_test.py b/sources/pyside6/tests/QtCore/versioninfo_test.py index 85d774dde..63414378a 100644 --- a/sources/pyside6/tests/QtCore/versioninfo_test.py +++ b/sources/pyside6/tests/QtCore/versioninfo_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys |