aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/pysidetest
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/pysidetest')
-rw-r--r--sources/pyside6/tests/pysidetest/CMakeLists.txt65
-rw-r--r--sources/pyside6/tests/pysidetest/all_modules_load_test.py29
-rw-r--r--sources/pyside6/tests/pysidetest/bug_1016.py29
-rw-r--r--sources/pyside6/tests/pysidetest/constructor_properties_test.py114
-rw-r--r--sources/pyside6/tests/pysidetest/container_test.py50
-rw-r--r--sources/pyside6/tests/pysidetest/containertest.cpp67
-rw-r--r--sources/pyside6/tests/pysidetest/containertest.h37
-rw-r--r--sources/pyside6/tests/pysidetest/decoratedslot_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/enum_test.py209
-rw-r--r--sources/pyside6/tests/pysidetest/flagstest.cpp29
-rw-r--r--sources/pyside6/tests/pysidetest/flagstest.h33
-rw-r--r--sources/pyside6/tests/pysidetest/hiddenobject.cpp31
-rw-r--r--sources/pyside6/tests/pysidetest/hiddenobject.h35
-rw-r--r--sources/pyside6/tests/pysidetest/homonymoussignalandmethod_test.py74
-rw-r--r--sources/pyside6/tests/pysidetest/iterable_test.py29
-rw-r--r--sources/pyside6/tests/pysidetest/list_signal_test.py31
-rw-r--r--sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/mock_as_slot_test.py33
-rw-r--r--sources/pyside6/tests/pysidetest/modelview_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/multiple_inheritance_test.py189
-rw-r--r--sources/pyside6/tests/pysidetest/new_inherited_functions_test.py34
-rw-r--r--sources/pyside6/tests/pysidetest/notify_id.py32
-rw-r--r--sources/pyside6/tests/pysidetest/properties_test.py29
-rw-r--r--sources/pyside6/tests/pysidetest/property_python_test.py32
-rw-r--r--sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py136
-rw-r--r--sources/pyside6/tests/pysidetest/pysidetest.pyproject33
-rw-r--r--sources/pyside6/tests/pysidetest/pysidetest_global.h31
-rw-r--r--sources/pyside6/tests/pysidetest/pysidetest_macros.h29
-rw-r--r--sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py29
-rw-r--r--sources/pyside6/tests/pysidetest/qvariant_test.py75
-rw-r--r--sources/pyside6/tests/pysidetest/repr_test.py53
-rw-r--r--sources/pyside6/tests/pysidetest/shared_pointer_test.py54
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp46
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.h29
-rw-r--r--sources/pyside6/tests/pysidetest/signal_slot_warning.py30
-rw-r--r--sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/signalandnamespace_test.py30
-rw-r--r--sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py33
-rw-r--r--sources/pyside6/tests/pysidetest/signalinstance_equality_test.py85
-rw-r--r--sources/pyside6/tests/pysidetest/signalwithdefaultvalue_test.py47
-rw-r--r--sources/pyside6/tests/pysidetest/snake_case_sub.py23
-rw-r--r--sources/pyside6/tests/pysidetest/snake_case_test.py38
-rw-r--r--sources/pyside6/tests/pysidetest/testobject.cpp49
-rw-r--r--sources/pyside6/tests/pysidetest/testobject.h55
-rw-r--r--sources/pyside6/tests/pysidetest/testqvariantenum.cpp29
-rw-r--r--sources/pyside6/tests/pysidetest/testqvariantenum.h35
-rw-r--r--sources/pyside6/tests/pysidetest/testview.cpp39
-rw-r--r--sources/pyside6/tests/pysidetest/testview.h34
-rw-r--r--sources/pyside6/tests/pysidetest/true_property_test.py58
-rw-r--r--sources/pyside6/tests/pysidetest/typedef_signal_test.py44
-rw-r--r--sources/pyside6/tests/pysidetest/typesystem_pysidetest.xml17
-rw-r--r--sources/pyside6/tests/pysidetest/version_test.py30
53 files changed, 1406 insertions, 1146 deletions
diff --git a/sources/pyside6/tests/pysidetest/CMakeLists.txt b/sources/pyside6/tests/pysidetest/CMakeLists.txt
index d63326eb9..38f42f342 100644
--- a/sources/pyside6/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside6/tests/pysidetest/CMakeLists.txt
@@ -1,7 +1,10 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
project(pysidetest)
project(testbinding)
-cmake_minimum_required(VERSION 3.16)
+cmake_minimum_required(VERSION 3.18)
set(QT_USE_QTCORE 1)
# no more supported: include(${QT_USE_FILE})
@@ -14,14 +17,18 @@ set(CMAKE_AUTOMOC ON)
add_definitions(-DQT_SHARED)
add_definitions(-DRXX_ALLOCATOR_INIT_0)
-find_package(Qt${QT_MAJOR_VERSION}Widgets)
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
set(pysidetest_SRC
-containertest.cpp
-flagstest.cpp
-testobject.cpp
-testview.cpp
-hiddenobject.cpp
+containertest.cpp containertest.h
+flagstest.cpp flagstest.h
+hiddenobject.cpp hiddenobject.h
+pysidetest_global.h
+pysidetest_macros.h
+sharedpointertestbench.cpp sharedpointertestbench.h
+testobject.cpp testobject.h
+testview.cpp testview.h
+testqvariantenum.cpp testqvariantenum.h
)
set(testbinding_SRC
@@ -33,8 +40,13 @@ ${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobjectwithnamespace_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobject2withnamespace_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp2_testobjectwithoutnamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/qsharedpointer_qobject_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/qsharedpointer_int_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/sharedpointertestbench_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testview_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/testqvariantenum_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/qvariantholder_wrapper.cpp
)
# Get per module include dirs.
@@ -69,10 +81,15 @@ make_path(testbinding_include_dirs ${pyside6_BINARY_DIR}
make_path(testbinding_typesystem_path ${pyside6_SOURCE_DIR}
${pyside6_BINARY_DIR})
+shiboken_get_tool_shell_wrapper(shiboken tool_wrapper)
+
add_custom_command(
-OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
- BYPRODUCTS ${testbinding_SRC}
- COMMAND Shiboken6::shiboken6 ${GENERATOR_EXTRA_FLAGS}
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+ BYPRODUCTS ${testbinding_SRC}
+ COMMAND
+ ${tool_wrapper}
+ $<TARGET_FILE:Shiboken6::shiboken6>
+ ${GENERATOR_EXTRA_FLAGS}
${CMAKE_CURRENT_SOURCE_DIR}/pysidetest_global.h
--include-paths=${testbinding_include_dirs}
${shiboken_framework_include_dirs_option}
@@ -80,8 +97,8 @@ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
--output-directory=${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/typesystem_pysidetest.xml
--api-version=${SUPPORTED_QT_VERSION}
-WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-COMMENT "Running generator for test binding..."
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Running generator for test binding..."
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
@@ -101,10 +118,7 @@ set_target_properties(pysidetest PROPERTIES
target_link_libraries(pysidetest
Shiboken6::libshiboken
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
- )
+ Qt::Core Qt::Gui Qt::Widgets)
add_library(testbinding MODULE ${testbinding_SRC})
set_property(TARGET testbinding PROPERTY PREFIX "")
@@ -113,25 +127,17 @@ if(WIN32)
set_property(TARGET testbinding PROPERTY SUFFIX ".pyd")
endif()
-if(PYTHON_LIMITED_API)
- set(TESTBINDING_PYTHON_LIBS ${PYTHON_LIMITED_LIBRARIES})
-else()
- set(TESTBINDING_PYTHON_LIBS ${PYTHON_LIBRARIES})
-endif()
-
target_link_libraries(testbinding
pysidetest
pyside6
- ${TESTBINDING_PYTHON_LIBS}
Shiboken6::libshiboken
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES})
+ Qt::Core Qt::Gui Qt::Widgets)
add_dependencies(testbinding pyside6 QtCore QtGui QtWidgets pysidetest)
create_generator_target(testbinding)
PYSIDE_TEST(constructor_properties_test.py)
+PYSIDE_TEST(container_test.py)
PYSIDE_TEST(decoratedslot_test.py)
PYSIDE_TEST(delegatecreateseditor_test.py)
PYSIDE_TEST(all_modules_load_test.py)
@@ -142,17 +148,24 @@ PYSIDE_TEST(iterable_test.py)
PYSIDE_TEST(list_signal_test.py)
PYSIDE_TEST(mixin_signal_slots_test.py)
PYSIDE_TEST(modelview_test.py)
+PYSIDE_TEST(multiple_inheritance_test.py)
PYSIDE_TEST(new_inherited_functions_test.py)
PYSIDE_TEST(notify_id.py)
PYSIDE_TEST(properties_test.py)
PYSIDE_TEST(property_python_test.py)
+PYSIDE_TEST(snake_case_test.py)
+PYSIDE_TEST(true_property_test.py)
PYSIDE_TEST(qapp_like_a_macro_test.py)
PYSIDE_TEST(qvariant_test.py)
PYSIDE_TEST(repr_test.py)
+PYSIDE_TEST(shared_pointer_test.py)
PYSIDE_TEST(signal_tp_descr_get_test.py)
PYSIDE_TEST(signal_slot_warning.py)
PYSIDE_TEST(signalandnamespace_test.py)
PYSIDE_TEST(signalemissionfrompython_test.py)
+PYSIDE_TEST(signalinstance_equality_test.py)
PYSIDE_TEST(signalwithdefaultvalue_test.py)
PYSIDE_TEST(typedef_signal_test.py)
PYSIDE_TEST(version_test.py)
+PYSIDE_TEST(mock_as_slot_test.py)
+PYSIDE_TEST(pyenum_relax_options_test.py)
diff --git a/sources/pyside6/tests/pysidetest/all_modules_load_test.py b/sources/pyside6/tests/pysidetest/all_modules_load_test.py
index f8f2d4b79..454c2b14f 100644
--- a/sources/pyside6/tests/pysidetest/all_modules_load_test.py
+++ b/sources/pyside6/tests/pysidetest/all_modules_load_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/pysidetest/bug_1016.py b/sources/pyside6/tests/pysidetest/bug_1016.py
index db57302a2..219384e66 100644
--- a/sources/pyside6/tests/pysidetest/bug_1016.py
+++ b/sources/pyside6/tests/pysidetest/bug_1016.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/pysidetest/constructor_properties_test.py b/sources/pyside6/tests/pysidetest/constructor_properties_test.py
index e3e1d0f75..ec6e39821 100644
--- a/sources/pyside6/tests/pysidetest/constructor_properties_test.py
+++ b/sources/pyside6/tests/pysidetest/constructor_properties_test.py
@@ -1,41 +1,5 @@
-#############################################################################
-##
-## Copyright (C) 2019 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
@@ -51,20 +15,82 @@ from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QAction
from PySide6.QtWidgets import QApplication, QLabel, QFrame
+is_pypy = hasattr(sys, "pypy_version_info")
+if not is_pypy:
+ from PySide6.support import feature
-class ConstructorPropertiesTest(UsesQApplication):
+
+class ConstructorPropertiesTest(unittest.TestCase):
+
+ def setUp(self):
+ qApp or QApplication()
+ if not is_pypy:
+ feature.reset()
+
+ def tearDown(self):
+ if not is_pypy:
+ feature.reset()
+ qApp.shutdown()
# PYSIDE-1019: First property extension was support by the constructor.
def testCallConstructor(self):
label = QLabel(
- frameStyle=QFrame.Panel | QFrame.Sunken,
- text="first line\nsecond line",
- alignment=Qt.AlignBottom | Qt.AlignRight
+ frameStyle=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
+ lineWidth=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
)
+ self.assertEqual(label.lineWidth(), 2)
self.assertRaises(AttributeError, lambda: QLabel(
somethingelse=42,
- text="first line\nsecond line",
- alignment=Qt.AlignBottom | Qt.AlignRight
+ ))
+
+ # PYSIDE-1705: The same with snake_case
+ @unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
+ def testCallConstructor_snake(self):
+ from __feature__ import snake_case
+
+ label = QLabel(
+ frame_style=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
+ line_width=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ )
+ self.assertEqual(label.line_width(), 2)
+ self.assertRaises(AttributeError, lambda: QLabel(
+ lineWidth=2, # QFrame property
+ ))
+
+ # PYSIDE-1705: The same with true_property
+ @unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
+ def testCallConstructor_prop(self):
+ from __feature__ import true_property
+
+ label = QLabel(
+ frameStyle=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
+ lineWidth=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ )
+ self.assertEqual(label.lineWidth, 2)
+ self.assertRaises(AttributeError, lambda: QLabel(
+ line_width=2, # QFrame property
+ ))
+
+ # PYSIDE-1705: The same with snake_case and true_property
+ @unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
+ def testCallConstructor_prop_snake(self):
+ from __feature__ import snake_case, true_property
+
+ label = QLabel(
+ frame_style=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
+ line_width=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ )
+ self.assertEqual(label.line_width, 2)
+ self.assertRaises(AttributeError, lambda: QLabel(
+ lineWidth=2, # QFrame property
))
diff --git a/sources/pyside6/tests/pysidetest/container_test.py b/sources/pyside6/tests/pysidetest/container_test.py
index 14feb4465..c83e1f26c 100644
--- a/sources/pyside6/tests/pysidetest/container_test.py
+++ b/sources/pyside6/tests/pysidetest/container_test.py
@@ -1,32 +1,5 @@
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## 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
@@ -45,6 +18,9 @@ EXPECTED_DICT = {1: ["v1"], 2: ["v2_1", "v2_2"],
4: ["v4_1", "v4_2"]}
+EXPECTED_LIST = [1, 2]
+
+
def sort_values(m):
"""Sort value lists in dicts since passing through a QMultiMap changes the order"""
result = {}
@@ -67,7 +43,21 @@ class ContainerTestTest(unittest.TestCase):
m2 = ContainerTest.passThroughMultiHash(m1)
self.assertEqual(sort_values(m2), EXPECTED_DICT)
+ def testList(self):
+ l1 = ContainerTest.createList()
+ self.assertEqual(l1, EXPECTED_LIST)
+ l2 = ContainerTest.passThroughList(l1)
+ self.assertEqual(l2, EXPECTED_LIST)
+
+ def testSet(self):
+ s1 = ContainerTest.createSet() # Order is not predictable
+ s2 = ContainerTest.passThroughSet(s1)
+ self.assertEqual(sorted(list(s1)), sorted(list(s2)))
+
+ # Since lists are iterable, it should be possible to pass them to set API
+ l2 = ContainerTest.passThroughSet(EXPECTED_LIST)
+ self.assertEqual(sorted(list(l2)), EXPECTED_LIST)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/pyside6/tests/pysidetest/containertest.cpp b/sources/pyside6/tests/pysidetest/containertest.cpp
index ccb90b12f..da8729af3 100644
--- a/sources/pyside6/tests/pysidetest/containertest.cpp
+++ b/sources/pyside6/tests/pysidetest/containertest.cpp
@@ -1,42 +1,19 @@
-/****************************************************************************
-**
-** 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) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "containertest.h"
+using namespace Qt::StringLiterals;
+
ContainerTest::ContainerTest() = default;
QMultiMap<int, QString> ContainerTest::createMultiMap()
{
static const QMultiMap<int, QString>
- result{{1, u"v1"_qs},
- {2, u"v2_1"_qs}, {2, u"v2_2"_qs},
- {3, u"v3"_qs},
- {4, u"v4_1"_qs}, {4, u"v4_2"_qs}};
+ result{{1, u"v1"_s},
+ {2, u"v2_1"_s}, {2, u"v2_2"_s},
+ {3, u"v3"_s},
+ {4, u"v4_1"_s}, {4, u"v4_2"_s}};
return result;
}
@@ -48,10 +25,10 @@ QMultiMap<int, QString> ContainerTest::passThroughMultiMap(const QMultiMap<int,
QMultiHash<int, QString> ContainerTest::createMultiHash()
{
static const QMultiHash<int, QString>
- result{{1, u"v1"_qs},
- {2, u"v2_1"_qs}, {2, u"v2_2"_qs},
- {3, u"v3"_qs},
- {4, u"v4_1"_qs}, {4, u"v4_2"_qs}};
+ result{{1, u"v1"_s},
+ {2, u"v2_1"_s}, {2, u"v2_2"_s},
+ {3, u"v3"_s},
+ {4, u"v4_1"_s}, {4, u"v4_2"_s}};
return result;
}
@@ -60,3 +37,23 @@ QMultiHash<int, QString> ContainerTest::passThroughMultiHash(const QMultiHash<in
{
return in;
}
+
+QList<int> ContainerTest::createList()
+{
+ return {1, 2};
+}
+
+QList<int> ContainerTest::passThroughList(const QList<int> &list)
+{
+ return list;
+}
+
+QSet<int> ContainerTest::createSet()
+{
+ return {1, 2};
+}
+
+QSet<int> ContainerTest::passThroughSet(const QSet<int> &set)
+{
+ return set;
+}
diff --git a/sources/pyside6/tests/pysidetest/containertest.h b/sources/pyside6/tests/pysidetest/containertest.h
index 3405b6722..068fb3c19 100644
--- a/sources/pyside6/tests/pysidetest/containertest.h
+++ b/sources/pyside6/tests/pysidetest/containertest.h
@@ -1,39 +1,16 @@
-/****************************************************************************
-**
-** 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) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "pysidetest_macros.h"
#include <QtCore/QObject>
+#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QMultiMap>
#include <QtCore/QMultiHash>
+#include <QtCore/QSet>
#include <QtCore/QString>
class PYSIDETEST_API ContainerTest
@@ -48,4 +25,10 @@ public:
static QMultiHash<int, QString> createMultiHash();
static QMultiHash<int, QString> passThroughMultiHash(const QMultiHash<int, QString> &in);
+
+ static QList<int> createList();
+ static QList<int> passThroughList(const QList<int> &list);
+
+ static QSet<int> createSet();
+ static QSet<int> passThroughSet(const QSet<int> &set);
};
diff --git a/sources/pyside6/tests/pysidetest/decoratedslot_test.py b/sources/pyside6/tests/pysidetest/decoratedslot_test.py
index 6db8cafc3..3ec9ac9e3 100644
--- a/sources/pyside6/tests/pysidetest/decoratedslot_test.py
+++ b/sources/pyside6/tests/pysidetest/decoratedslot_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/pysidetest/delegatecreateseditor_test.py b/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py
index 9d1c5bf2b..8964ec1ed 100644
--- a/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py
+++ b/sources/pyside6/tests/pysidetest/delegatecreateseditor_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/pysidetest/enum_test.py b/sources/pyside6/tests/pysidetest/enum_test.py
index 61febb299..7afc5b948 100644
--- a/sources/pyside6/tests/pysidetest/enum_test.py
+++ b/sources/pyside6/tests/pysidetest/enum_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) 2024 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,8 +10,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(True)
+from PySide6.QtCore import Qt
from testbinding import Enum1, TestObjectWithoutNamespace
+import dis
+
class ListConnectionTest(unittest.TestCase):
@@ -48,7 +24,180 @@ class ListConnectionTest(unittest.TestCase):
self.assertEqual(TestObjectWithoutNamespace.Enum2.Option3, 3)
self.assertEqual(TestObjectWithoutNamespace.Enum2.Option4, 4)
+ def testFlagComparisonOperators(self): # PYSIDE-1696, compare to self
+ f1 = Qt.AlignHCenter | Qt.AlignBottom
+ f2 = Qt.AlignHCenter | Qt.AlignBottom
+ self.assertTrue(f1 == f1)
+ self.assertTrue(f1 <= f1)
+ self.assertTrue(f1 >= f1)
+ self.assertFalse(f1 != f1)
+ self.assertFalse(f1 < f1)
+ self.assertFalse(f1 > f1)
+
+ self.assertTrue(f1 == f2)
+ self.assertTrue(f1 <= f2)
+ self.assertTrue(f1 >= f2)
+ self.assertFalse(f1 != f2)
+ self.assertFalse(f1 < f2)
+ self.assertFalse(f1 > f2)
+
+ self.assertTrue(Qt.AlignHCenter < Qt.AlignBottom)
+ self.assertFalse(Qt.AlignHCenter > Qt.AlignBottom)
+ self.assertFalse(Qt.AlignBottom < Qt.AlignHCenter)
+ self.assertTrue(Qt.AlignBottom > Qt.AlignHCenter)
+
+
+# PYSIDE-1735: We are testing that opcodes do what they are supposed to do.
+# This is needed in the PyEnum forgiveness mode where we need
+# to introspect the code if an Enum was called with no args.
+
+# flake8: noqa
+class InvestigateOpcodesTest(unittest.TestCase):
+
+ def probe_function1(self):
+ x = Qt.Alignment
+
+ def probe_function2(self):
+ x = Qt.Alignment()
+
+ @staticmethod
+ def read_code(func, **kw):
+ return list(instr[:3] for instr in dis.Bytecode(func, **kw))
+
+ @staticmethod
+ def get_sizes(func, **kw):
+ ops = list((instr.opname, instr.offset) for instr in dis.Bytecode(func, **kw))
+ res = []
+ for idx in range(1, len(ops)):
+ res.append((ops[idx - 1][0], ops[idx][1] - ops[idx - 1][1]))
+ return sorted(res, key=lambda x: (x[1], x[0]))
+
+ _sin = sys.implementation.name
+
+ @unittest.skipIf(hasattr(sys.flags, "nogil"), f"{_sin} has different opcodes")
+ def testByteCode(self):
+ import dis
+ # opname, opcode, arg
+ result_1 = [('LOAD_GLOBAL', 116, 0),
+ ('LOAD_ATTR', 106, 1),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ result_2 = [('LOAD_GLOBAL', 116, 0),
+ ('LOAD_METHOD', 160, 1),
+ ('CALL_METHOD', 161, 0),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ if sys.version_info[:2] <= (3, 6):
+
+ result_2 = [('LOAD_GLOBAL', 116, 0),
+ ('LOAD_ATTR', 106, 1),
+ ('CALL_FUNCTION', 131, 0),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ if sys.version_info[:2] == (3, 11):
+ # Note: Python 3.11 is a bit more complex because it can optimize itself.
+ # Opcodes are a bit different, and a hidden second code object is used.
+ # We investigate this a bit, because we want to be warned when things change.
+ QUICKENING_WARMUP_DELAY = 8
+
+ result_1 = [('RESUME', 151, 0),
+ ('LOAD_GLOBAL', 116, 0),
+ ('LOAD_ATTR', 106, 1),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ result_2 = [('RESUME', 151, 0),
+ ('LOAD_GLOBAL', 116, 1),
+ ('LOAD_ATTR', 106, 1),
+ ('PRECALL', 166, 0),
+ ('CALL', 171, 0),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ sizes_2 = [('LOAD_CONST', 2),
+ ('RESUME', 2),
+ ('STORE_FAST', 2),
+ ('PRECALL', 4),
+ ('CALL', 10),
+ ('LOAD_ATTR', 10),
+ ('LOAD_GLOBAL', 12)]
+
+ self.assertEqual(self.read_code(self.probe_function2, adaptive=True), result_2)
+ self.assertEqual(self.get_sizes(self.probe_function2, adaptive=True), sizes_2)
+
+ @staticmethod
+ def code_quicken(f, times):
+ # running the code triggers acceleration after some runs.
+ for _ in range(times):
+ f()
+
+ code_quicken(self.probe_function2, QUICKENING_WARMUP_DELAY - 1)
+ self.assertEqual(self.read_code(self.probe_function2, adaptive=True), result_2)
+ self.assertEqual(self.get_sizes(self.probe_function2, adaptive=True), sizes_2)
+
+ result_3 = [('RESUME_QUICK', 150, 0),
+ ('LOAD_GLOBAL_MODULE', 55, 1),
+ ('LOAD_ATTR_ADAPTIVE', 39, 1),
+ ('PRECALL_ADAPTIVE', 64, 0),
+ ('CALL_ADAPTIVE', 22, 0),
+ ('STORE_FAST', 125, 1),
+ ('LOAD_CONST', 100, 0),
+ ('RETURN_VALUE', 83, None)]
+
+ sizes_3 = [('LOAD_CONST', 2),
+ ('RESUME_QUICK', 2),
+ ('STORE_FAST', 2),
+ ('PRECALL_ADAPTIVE', 4),
+ ('CALL_ADAPTIVE', 10),
+ ('LOAD_ATTR_ADAPTIVE', 10),
+ ('LOAD_GLOBAL_MODULE', 12)]
+
+ code_quicken(self.probe_function2, 1)
+ self.assertEqual(self.read_code(self.probe_function2, adaptive=True), result_3)
+ self.assertEqual(self.get_sizes(self.probe_function2, adaptive=True), sizes_3)
+
+ if sys.version_info[:2] == (3, 12):
+
+ result_1 = [('RESUME', 151, 0),
+ ('LOAD_GLOBAL', 116, 0),
+ ('LOAD_ATTR', 106, 2),
+ ('STORE_FAST', 125, 1),
+ ('RETURN_CONST', 121, 0)]
+
+ result_2 = [('RESUME', 151, 0),
+ ('LOAD_GLOBAL', 116, 1),
+ ('LOAD_ATTR', 106, 2),
+ ('CALL', 171, 0),
+ ('STORE_FAST', 125, 1),
+ ('RETURN_CONST', 121, 0)]
+
+ if sys.version_info[:2] >= (3, 13):
+
+ result_1 = [('RESUME', 149, 0),
+ ('LOAD_GLOBAL', 91, 0),
+ ('LOAD_ATTR', 82, 2),
+ ('STORE_FAST', 110, 1),
+ ('RETURN_CONST', 103, 0)]
+
+ result_2 = [('RESUME', 149, 0),
+ ('LOAD_GLOBAL', 91, 0),
+ ('LOAD_ATTR', 82, 2),
+ ('PUSH_NULL', 34, None),
+ ('CALL', 53, 0),
+ ('STORE_FAST', 110, 1),
+ ('RETURN_CONST', 103, 0)]
+
+ self.assertEqual(self.read_code(self.probe_function1), result_1)
+ self.assertEqual(self.read_code(self.probe_function2), result_2)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/pyside6/tests/pysidetest/flagstest.cpp b/sources/pyside6/tests/pysidetest/flagstest.cpp
index 2bd0c454e..ac6c3b3b1 100644
--- a/sources/pyside6/tests/pysidetest/flagstest.cpp
+++ b/sources/pyside6/tests/pysidetest/flagstest.cpp
@@ -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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "flagstest.h"
diff --git a/sources/pyside6/tests/pysidetest/flagstest.h b/sources/pyside6/tests/pysidetest/flagstest.h
index 7f070361c..b5c73c9bd 100644
--- a/sources/pyside6/tests/pysidetest/flagstest.h
+++ b/sources/pyside6/tests/pysidetest/flagstest.h
@@ -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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -48,8 +23,10 @@ class PYSIDETEST_API ClassForEnum : public QObject
{
Q_OBJECT
public:
+ Q_DISABLE_COPY_MOVE(ClassForEnum)
+
ClassForEnum(FlagsNamespace::Options opt = FlagsNamespace::Option::NoOptions);
- virtual ~ClassForEnum();
+ virtual ~ClassForEnum() override;
};
} // namespace FlagsNamespace
diff --git a/sources/pyside6/tests/pysidetest/hiddenobject.cpp b/sources/pyside6/tests/pysidetest/hiddenobject.cpp
index 70692a8ec..d4feabb66 100644
--- a/sources/pyside6/tests/pysidetest/hiddenobject.cpp
+++ b/sources/pyside6/tests/pysidetest/hiddenobject.cpp
@@ -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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "hiddenobject.h"
@@ -33,7 +8,7 @@ void HiddenObject::callMe()
m_called = true;
}
-bool HiddenObject::wasCalled()
+bool HiddenObject::wasCalled() const
{
return m_called;
}
diff --git a/sources/pyside6/tests/pysidetest/hiddenobject.h b/sources/pyside6/tests/pysidetest/hiddenobject.h
index 97a2864c5..f399be985 100644
--- a/sources/pyside6/tests/pysidetest/hiddenobject.h
+++ b/sources/pyside6/tests/pysidetest/hiddenobject.h
@@ -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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef HIDDENOBJECT_H
#define HIDDENOBJECT_H
@@ -38,12 +13,12 @@ class HiddenObject : public QObject
{
Q_OBJECT
public:
- HiddenObject() : m_called(false) {}
+ HiddenObject() noexcept = default;
Q_INVOKABLE void callMe();
public Q_SLOTS:
- bool wasCalled();
+ bool wasCalled() const;
private:
- bool m_called;
+ bool m_called = false;
};
// Return a instance of HiddenObject
diff --git a/sources/pyside6/tests/pysidetest/homonymoussignalandmethod_test.py b/sources/pyside6/tests/pysidetest/homonymoussignalandmethod_test.py
index b29d37fc2..b58232a1b 100644
--- a/sources/pyside6/tests/pysidetest/homonymoussignalandmethod_test.py
+++ b/sources/pyside6/tests/pysidetest/homonymoussignalandmethod_test.py
@@ -1,33 +1,8 @@
#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#############################################################################
-##
-## 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$
-##
-#############################################################################
-
+import gc
import os
import sys
import unittest
@@ -38,6 +13,7 @@ from init_paths import init_test_paths
init_test_paths(True)
from testbinding import TestObject
+from PySide6.QtCore import QObject, Signal, SignalInstance
'''Tests the behaviour of homonymous signals and slots.'''
@@ -53,6 +29,8 @@ class HomonymousSignalAndMethodTest(unittest.TestCase):
del self.value
del self.called
del self.obj
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def testIdValueSignalEmission(self):
def callback(idValue):
@@ -86,6 +64,46 @@ class HomonymousSignalAndMethodTest(unittest.TestCase):
self.assertEqual(self.obj.staticMethodDouble(4), 8)
+# PYSIDE-1730: Homonymous Methods with multiple inheritance
+
+class Q(QObject):
+ signal = Signal()
+
+ def method(self):
+ msg = 'Q::method'
+ print(msg)
+ return msg
+
+
+class M:
+
+ def signal(self):
+ msg = 'M::signal'
+ print(msg)
+ return msg
+
+ def method(self):
+ msg = 'M::method'
+ print(msg)
+ return msg
+
+
+class C(M, Q):
+
+ def __init__(self):
+ Q.__init__(self)
+ M.__init__(self)
+
+
+class HomonymousMultipleInheritanceTest(unittest.TestCase):
+
+ def testHomonymousMultipleInheritance(self):
+ c = C()
+ self.assertEqual(c.method(), "M::method") # okay
+ self.assertEqual(c.signal(), "M::signal") # problem on PySide6 6.2.2
+ self.assertEqual(type(c.signal), SignalInstance)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/iterable_test.py b/sources/pyside6/tests/pysidetest/iterable_test.py
index d2bf8c9f2..bdb2ae7be 100644
--- a/sources/pyside6/tests/pysidetest/iterable_test.py
+++ b/sources/pyside6/tests/pysidetest/iterable_test.py
@@ -1,30 +1,5 @@
-#############################################################################
-##
-## 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
"""
iterable_test.py
diff --git a/sources/pyside6/tests/pysidetest/list_signal_test.py b/sources/pyside6/tests/pysidetest/list_signal_test.py
index 93b8514d7..da4bc298d 100644
--- a/sources/pyside6/tests/pysidetest/list_signal_test.py
+++ b/sources/pyside6/tests/pysidetest/list_signal_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/pysidetest/mixin_signal_slots_test.py b/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py
index 19b9a583e..1d536c0ae 100644
--- a/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py
+++ b/sources/pyside6/tests/pysidetest/mixin_signal_slots_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
''' PYSIDE-315: https://bugreports.qt.io/browse/PYSIDE-315
Test that all signals and slots of a class (including any mixin classes)
diff --git a/sources/pyside6/tests/pysidetest/mock_as_slot_test.py b/sources/pyside6/tests/pysidetest/mock_as_slot_test.py
new file mode 100644
index 000000000..39f52adea
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/mock_as_slot_test.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+""" PYSIDE-1755: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1755
+ Tests that a unittest.mock.MagicMock() can be used as a slot for quick
+ prototyping. """
+
+import os
+import sys
+import unittest
+from unittest.mock import MagicMock
+
+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 QObject
+
+
+class MockAsSlot(unittest.TestCase):
+ def testMockAsSlot(self):
+ obj = QObject()
+ mock = MagicMock()
+ obj.objectNameChanged.connect(mock)
+
+ obj.objectNameChanged.emit("test")
+ mock.assert_called_once()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/modelview_test.py b/sources/pyside6/tests/pysidetest/modelview_test.py
index 3329b5875..53231aebe 100644
--- a/sources/pyside6/tests/pysidetest/modelview_test.py
+++ b/sources/pyside6/tests/pysidetest/modelview_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/pysidetest/multiple_inheritance_test.py b/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py
new file mode 100644
index 000000000..49550ba55
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py
@@ -0,0 +1,189 @@
+# Copyright (C) 2023 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 import QtCore, QtGui, QtWidgets
+from PySide6.QtWidgets import QMainWindow, QLabel, QWidget
+
+
+def xprint(*args, **kw):
+ if "-v" in sys.argv:
+ print(*args, **kw)
+
+
+# This is the original testcase of PYSIDE-1564
+class Age(object):
+ def __init__(self, age=0, **kwds):
+ super().__init__(**kwds)
+
+ self.age = age
+
+
+class Person(QtCore.QObject, Age):
+ def __init__(self, name, **kwds):
+ super().__init__(**kwds)
+
+ self.name = name
+
+
+class OriginalMultipleInheritanceTest(unittest.TestCase):
+
+ def testIt(self):
+ xprint()
+ p = Person("Joe", age=38)
+ xprint(f"p.age = {p.age}")
+ # This would crash if MI does not work.
+
+# More tests follow:
+
+
+# mro ('C', 'A', 'QObject', 'Object', 'B', 'object')
+class A(QtCore.QObject):
+ def __init__(self, anna=77, **kw):
+ xprint(f'A: before init kw = {kw}')
+ super().__init__(**kw)
+ xprint('A: after init')
+
+
+class B:
+ def __init__(self, otto=6, age=7, **kw):
+ xprint(f'B: before init kw = {kw}')
+ if "killme" in kw:
+ raise AssertionError("asdf")
+ super().__init__(**kw)
+ self.age = age
+ xprint('B: after init')
+
+
+class C(A, B):
+ def __init__(self, **kw):
+ xprint(f'C: before init kw = {kw}')
+ super().__init__(**kw)
+ xprint('C: after init')
+
+
+# mro ('F', 'D', 'QCursor', 'E', 'QLabel', 'QFrame', 'QWidget', 'QObject',
+# 'QPaintDevice', 'Object', 'object')
+class D(QtGui.QCursor):
+ def __init__(self, anna=77, **kw):
+ xprint(f'D: before init kw = {kw}')
+ super().__init__(**kw)
+ xprint('D: after init')
+
+
+class E:
+ def __init__(self, age=7, **kw):
+ xprint(f'E: before init kw = {kw}')
+ super().__init__(**kw)
+ self.age = age
+ xprint('E: after init')
+
+
+class F(D, E, QtWidgets.QLabel):
+ def __init__(self, **kw):
+ xprint(f'F: before init kw = {kw}')
+ super().__init__(**kw)
+ xprint('F: after init')
+
+
+# mro ('I', 'G', 'QTextDocument', 'H', 'QLabel', 'QFrame', 'QWidget', 'QObject',
+# 'QPaintDevice', 'Object', 'object')
+# Similar, but this time we want to reach `H` without support from `super`.
+class G(QtGui.QTextDocument):
+ pass
+
+
+class H:
+ def __init__(self, age=7, **kw):
+ xprint(f'H: before init kw = {kw}')
+ super().__init__(**kw)
+ self.age = age
+ xprint('H: after init')
+
+
+class II(G, H, QtWidgets.QLabel):
+ pass
+
+
+# PYSIDE-2294: Friedemann's test adapted.
+# We need to ignore positional args in mixin classes.
+class Ui_X_MainWindow(object): # Emulating uic
+ def setupUi(self, MainWindow):
+ MainWindow.resize(400, 300)
+ self.lbl = QLabel(self)
+
+
+class MainWindow(QMainWindow, Ui_X_MainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setupUi(self)
+
+
+class AdditionalMultipleInheritanceTest(UsesQApplication):
+
+ def testABC(self):
+ xprint()
+ res = C(otto=3, anna=5)
+ self.assertEqual(res.age, 7)
+ xprint()
+ with self.assertRaises(AssertionError):
+ res = C(killme=42)
+ xprint()
+
+ def testDEF(self):
+ xprint()
+ res = F(anna=5)
+ self.assertEqual(res.age, 7)
+ xprint()
+
+ def testGHI(self):
+ xprint()
+ res = II(age=7)
+ self.assertEqual(res.age, 7)
+ xprint()
+
+ def testParentDoesNotCrash(self):
+ # This crashed with
+ # TypeError: object.__init__() takes exactly one argument (the instance to initialize)
+ MainWindow()
+
+
+# PYSIDE-2654: Additional missing init test.
+# This must work if no __init__ is defined (Ui_Form)
+class Ui_Form(object):
+ pass
+
+
+class Mixin:
+ def __init__(self, **kwargs) -> None:
+ super().__init__(**kwargs)
+
+
+class Card(Mixin, QWidget):
+ def __init__(self, parent=None) -> None:
+ super().__init__(parent=parent)
+
+
+class Demo(Card, Ui_Form):
+ def __init__(self) -> None:
+ super().__init__()
+
+
+class MissingInitFunctionTest(UsesQApplication):
+ def testMissing(self):
+ Demo()
+ # Tests if this works. Would crash without the extra
+ # check for object.__init__
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
index 95bf0615f..924a2eea7 100644
--- a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
+++ b/sources/pyside6/tests/pysidetest/new_inherited_functions_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
@@ -36,6 +11,7 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide6 import *
+from PySide6.support.signature import get_signature
for modname, mod in sys.modules.items():
# Python 2 leaves "None" in the dict.
if modname.startswith("PySide6.") and mod is not None:
@@ -125,7 +101,7 @@ class MainTest(unittest.TestCase):
qint64 = 42
tfarg = os.path.join(PySide6.QtCore.QDir.tempPath(), "XXXXXX.tmp")
findStr = 'bla'
- orientation = PySide6.QtCore.Qt.Orientation()
+ orientation = PySide6.QtCore.Qt.Orientations()
openMode = PySide6.QtCore.QIODevice.OpenMode(PySide6.QtCore.QIODevice.ReadOnly)
qModelIndex = PySide6.QtCore.QModelIndex()
transformationMode = PySide6.QtCore.Qt.TransformationMode()
@@ -175,7 +151,7 @@ class MainTest(unittest.TestCase):
except AttributeError:
unittest.TestCase().skipTest("this test makes only sense if QtWidgets is available.")
- sigs = PySide6.QtWidgets.QApplication.palette.__signature__
+ sigs = get_signature(PySide6.QtWidgets.QApplication.palette)
self.assertEqual(len(sigs), 3)
diff --git a/sources/pyside6/tests/pysidetest/notify_id.py b/sources/pyside6/tests/pysidetest/notify_id.py
index f11eacdda..0c4f39f66 100644
--- a/sources/pyside6/tests/pysidetest/notify_id.py
+++ b/sources/pyside6/tests/pysidetest/notify_id.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
@@ -71,6 +47,8 @@ class NotifyIdSignal(unittest.TestCase):
def tearDown(self):
del self.obj
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def testSignalEmission(self):
metaObject = self.obj.metaObject()
diff --git a/sources/pyside6/tests/pysidetest/properties_test.py b/sources/pyside6/tests/pysidetest/properties_test.py
index abd0b90b6..8eb7812d1 100644
--- a/sources/pyside6/tests/pysidetest/properties_test.py
+++ b/sources/pyside6/tests/pysidetest/properties_test.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
import os
import sys
diff --git a/sources/pyside6/tests/pysidetest/property_python_test.py b/sources/pyside6/tests/pysidetest/property_python_test.py
index baf4cdb01..1209aad4f 100644
--- a/sources/pyside6/tests/pysidetest/property_python_test.py
+++ b/sources/pyside6/tests/pysidetest/property_python_test.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
"""
Test for PySide's Property
@@ -39,6 +14,7 @@ This test is to ensure maximum compatibility.
# Test case for property
# more tests are in test_descr
+import gc
import os
import sys
import unittest
@@ -95,6 +71,8 @@ class BaseClass(QObject):
@spam.deleter
def spam(self):
del self._spam
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
class SubClass(BaseClass):
diff --git a/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py b/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py
new file mode 100644
index 000000000..625f9cdc5
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/pyenum_relax_options_test.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+"""
+PYSIDE-1735: Testing different relax options for Enums
+
+This test uses different configurations and initializes QtCore with it.
+Because re-initialization is not possible, the test uses a subprocess
+for it. This makes the test pretty slow.
+
+Maybe we should implement a way to re-initialize QtCore enums without
+using subprocess, just to speed this up??
+"""
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+import subprocess
+import tempfile
+from textwrap import dedent
+
+
+def runtest(program):
+ passed_path = os.fspath(Path(__file__).resolve().parents[1])
+ with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".py") as fp:
+ preamble = dedent(f"""
+ import os
+ import sys
+ from pathlib import Path
+ sys.path.append({passed_path!r})
+ from init_paths import init_test_paths
+ init_test_paths(False)
+ """)
+ print(preamble, program, file=fp)
+ fp.close()
+ try:
+ subprocess.run([sys.executable, fp.name], check=True, capture_output=True)
+ return True
+ except subprocess.CalledProcessError as e:
+ print(f"\ninfo: {e.__class__.__name__}: {e.stderr}")
+ return False
+ finally:
+ os.unlink(fp.name)
+
+
+def testprog2(option):
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ from enum import IntEnum
+ assert(issubclass(QtCore.Qt.DateFormat, IntEnum))
+ """))
+
+
+def testprog4(option):
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.QtDebugMsg
+ """))
+
+
+def testprog8_16(option):
+ # this test needs flag 16, or the effect would be hidden by forgiving mode
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.AlignTop
+ """))
+
+
+def testprog32(option):
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.Alignment
+ """))
+
+
+def testprog64(option):
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.AlignmentFlag()
+ """))
+
+
+def testprog128(option):
+ return runtest(dedent(f"""
+ sys.pyside6_option_python_enum = {option}
+ from PySide6 import QtCore
+ QtCore.Qt.Key(1234567)
+ """))
+
+
+class TestPyEnumRelaxOption(unittest.TestCase):
+ """
+ This test is a bit involved, because we cannot unload QtCore after it is loaded once.
+ We use subprocess to test different cases, anyway.
+ """
+
+ def test_enumIsIntEnum(self):
+ self.assertTrue(testprog2(2))
+ self.assertFalse(testprog2(4))
+
+ def test_globalDefault(self):
+ self.assertTrue(testprog4(4))
+ self.assertFalse(testprog4(1))
+ self.assertTrue(testprog4(12))
+
+ def test_localDefault(self):
+ self.assertTrue(testprog8_16(8 + 16))
+ self.assertFalse(testprog8_16(0 + 16))
+
+ def test_fakeRenames(self):
+ self.assertTrue(testprog32(1))
+ self.assertFalse(testprog32(32))
+
+ def test_zeroDefault(self):
+ self.assertTrue(testprog64(1))
+ self.assertFalse(testprog64(64))
+
+ def test_Missing(self):
+ self.assertTrue(testprog128(1))
+ self.assertFalse(testprog128(128))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/pysidetest.pyproject b/sources/pyside6/tests/pysidetest/pysidetest.pyproject
new file mode 100644
index 000000000..032d31c6f
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/pysidetest.pyproject
@@ -0,0 +1,33 @@
+{
+ "files": ["all_modules_load_test.py",
+ "bug_1016.py",
+ "constructor_properties_test.py",
+ "container_test.py",
+ "decoratedslot_test.py",
+ "delegatecreateseditor_test.py",
+ "enum_test.py",
+ "homonymoussignalandmethod_test.py",
+ "iterable_test.py",
+ "list_signal_test.py",
+ "mixin_signal_slots_test.py",
+ "mock_as_slot_test.py",
+ "modelview_test.py",
+ "new_inherited_functions_test.py",
+ "notify_id.py",
+ "properties_test.py",
+ "property_python_test.py",
+ "pyenum_relax_options_test.py",
+ "qapp_like_a_macro_test.py",
+ "qvariant_test.py",
+ "repr_test.py",
+ "shared_pointer_test.py",
+ "signal_slot_warning.py",
+ "signal_tp_descr_get_test.py",
+ "signalandnamespace_test.py",
+ "signalemissionfrompython_test.py",
+ "signalinstance_equality_test.py",
+ "signalwithdefaultvalue_test.py",
+ "typedef_signal_test.py",
+ "version_test.py",
+ "typesystem_pysidetest.xml"]
+}
diff --git a/sources/pyside6/tests/pysidetest/pysidetest_global.h b/sources/pyside6/tests/pysidetest/pysidetest_global.h
index 61dee53d9..6f784dc58 100644
--- a/sources/pyside6/tests/pysidetest/pysidetest_global.h
+++ b/sources/pyside6/tests/pysidetest/pysidetest_global.h
@@ -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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PYSIDETEST_GLOBAL_H
#define PYSIDETEST_GLOBAL_H
@@ -35,5 +10,7 @@
#include "testview.h"
#include "flagstest.h"
#include "hiddenobject.h"
+#include "sharedpointertestbench.h"
+#include "testqvariantenum.h"
#endif // PYSIDETEST_GLOBAL_H
diff --git a/sources/pyside6/tests/pysidetest/pysidetest_macros.h b/sources/pyside6/tests/pysidetest/pysidetest_macros.h
index b561efbbc..29bd0dc39 100644
--- a/sources/pyside6/tests/pysidetest/pysidetest_macros.h
+++ b/sources/pyside6/tests/pysidetest/pysidetest_macros.h
@@ -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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PYSIDETEST_MACROS_H
#define PYSIDETEST_MACROS_H
diff --git a/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py b/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py
index c83d2a860..2a3f34014 100644
--- a/sources/pyside6/tests/pysidetest/qapp_like_a_macro_test.py
+++ b/sources/pyside6/tests/pysidetest/qapp_like_a_macro_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/pysidetest/qvariant_test.py b/sources/pyside6/tests/pysidetest/qvariant_test.py
index 637aa95cf..faefc8169 100644
--- a/sources/pyside6/tests/pysidetest/qvariant_test.py
+++ b/sources/pyside6/tests/pysidetest/qvariant_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 enum
import os
import sys
import unittest
@@ -35,20 +11,57 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(True)
-from testbinding import TestObject
-from PySide6.QtCore import Qt
-from PySide6.QtGui import QKeySequence
+from testbinding import TestObject, TestQVariantEnum
+from PySide6.QtCore import Qt, QKeyCombination
+from PySide6.QtGui import QKeySequence, QAction
from helper.usesqapplication import UsesQApplication
+class PyTestQVariantEnum(TestQVariantEnum):
+ def __init__(self, var_enum):
+ super().__init__(var_enum)
+
+ def getRValEnum(self):
+ return Qt.Orientation.Vertical
+
+ def channelingEnum(self, rval_enum):
+ return (isinstance(rval_enum, enum.Enum)
+ and rval_enum == Qt.Orientation.Vertical)
+
+
class QVariantTest(UsesQApplication):
def testQKeySequenceQVariantOperator(self):
# bug #775
- ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
+ ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R)
self.assertEqual(TestObject.checkType(ks), 4107)
+ def testQKeySequenceMoreVariations(self):
+ QAction().setShortcut(Qt.CTRL | Qt.Key_B)
+ QAction().setShortcut(Qt.CTRL | Qt.ALT | Qt.Key_B)
+ QAction().setShortcut(Qt.CTRL | Qt.AltModifier | Qt.Key_B)
+ QAction().setShortcut(QKeySequence(QKeyCombination(Qt.CTRL | Qt.Key_B)))
+ QKeySequence(Qt.CTRL | Qt.Key_Q)
+
+ def testEnum(self):
+ # Testing C++ class
+ testqvariant = TestQVariantEnum(Qt.CheckState.Checked)
+ self.assertEqual(testqvariant.getLValEnum(), Qt.CheckState.Checked)
+ self.assertIsInstance(testqvariant.getLValEnum(), enum.Enum)
+ # in the case where we return a QVariant of C++ enum, it returns a
+ # QVariant(int) to Python unless explicitly handled manually by Shiboken
+ self.assertEqual(testqvariant.getRValEnum(), 1)
+ self.assertEqual(testqvariant.isEnumChanneled(), False)
+
+ # Testing Python child class
+ pytestqvariant = PyTestQVariantEnum(Qt.CheckState.Checked)
+ self.assertEqual(pytestqvariant.isEnumChanneled(), True)
+ # check toInt() conversion works for PyObjectWrapper
+ self.assertEqual(PyTestQVariantEnum.getNumberFromQVarEnum(Qt.Orientation.Vertical), 2)
+ # check toInt() conversion for IntEnum
+ self.assertEqual(PyTestQVariantEnum.getNumberFromQVarEnum(Qt.GestureType.TapGesture), 1)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/repr_test.py b/sources/pyside6/tests/pysidetest/repr_test.py
index dd9f08ea4..863f17657 100644
--- a/sources/pyside6/tests/pysidetest/repr_test.py
+++ b/sources/pyside6/tests/pysidetest/repr_test.py
@@ -1,44 +1,6 @@
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Copyright (C) 2019 Andreas Beckermann
-## 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.
+# Copyright (C) 2019 Andreas Beckermann
+# 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
@@ -87,6 +49,15 @@ class QObjectDerivedReprTest(unittest.TestCase):
# __repr__ should use the operator<<(QDebug,...) implementation
self.assertEqual(str(t), "TestObject2WithNamespace(injected_repr)")
+ def testLatin1StringField(self):
+ self.assertEqual(TestObject.LATIN1_TEST_FIELD, "test")
+
+ def testLatin1Setter(self):
+ to = TestObject(123)
+ value = "test"
+ to.setQLatin1String(value)
+ self.assertEqual(to.qLatin1String(), value)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/shared_pointer_test.py b/sources/pyside6/tests/pysidetest/shared_pointer_test.py
new file mode 100644
index 000000000..6f49d69b1
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/shared_pointer_test.py
@@ -0,0 +1,54 @@
+# 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
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(True)
+
+from PySide6.QtCore import QObject
+
+from testbinding import SharedPointerTestbench, QSharedPointer_QObject
+
+
+def create_qobject(name):
+ result = QObject()
+ result.setObjectName(name)
+ return result
+
+
+class SharedPointerTests(unittest.TestCase):
+
+ def testObjSharedPointer(self):
+ p = SharedPointerTestbench.createSharedPointerQObject()
+ self.assertEqual(p.objectName(), "TestObject")
+ SharedPointerTestbench.printSharedPointerQObject(p)
+ p = SharedPointerTestbench.createSharedPointerConstQObject()
+ SharedPointerTestbench.printSharedPointerConstQObject(p)
+
+ def testIntSharedPointer(self):
+ p = SharedPointerTestbench.createSharedPointerInt(42)
+ SharedPointerTestbench.printSharedPointerInt(p)
+
+ def testConstruction(self):
+ name1 = "CreatedQObject1"
+ p1 = QSharedPointer_QObject(create_qobject(name1))
+ self.assertTrue(p1)
+ self.assertEqual(p1.objectName(), name1)
+
+ p1.reset()
+ self.assertFalse(p1)
+
+ name2 = "CreatedQObject2"
+ p1.reset(create_qobject(name2))
+ self.assertTrue(p1)
+ self.assertEqual(p1.objectName(), name2)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
new file mode 100644
index 000000000..44c2a4fe0
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "sharedpointertestbench.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QDebug>
+
+using namespace Qt::StringLiterals;
+
+SharedPointerTestbench::SharedPointerTestbench() = default;
+
+QSharedPointer<int> SharedPointerTestbench::createSharedPointerInt(int v)
+{
+ return QSharedPointer<int>(new int(v));
+}
+
+void SharedPointerTestbench::printSharedPointerInt(const QSharedPointer<int> &p)
+{
+ qDebug() << __FUNCTION__ << *p;
+}
+
+QSharedPointer<QObject> SharedPointerTestbench::createSharedPointerQObject()
+{
+ QSharedPointer<QObject> result(new QObject);
+ result->setObjectName(u"TestObject"_s);
+ return result;
+}
+
+void SharedPointerTestbench::printSharedPointerQObject(const QSharedPointer<QObject> &p)
+{
+ qDebug() << __FUNCTION__ << p.data();
+}
+
+QSharedPointer<const QObject> SharedPointerTestbench::createSharedPointerConstQObject()
+{
+ auto *o = new QObject;
+ o->setObjectName(u"ConstTestObject"_s);
+ QSharedPointer<const QObject> result(o);
+ return result;
+}
+
+void SharedPointerTestbench::printSharedPointerConstQObject(const QSharedPointer<const QObject> &p)
+{
+ qDebug() << __FUNCTION__ << p.data();
+}
diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
new file mode 100644
index 000000000..b23fd1b6c
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
@@ -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
+
+#ifndef SHAREDPOINTERTESTBENCH_H
+#define SHAREDPOINTERTESTBENCH_H
+
+#include "pysidetest_macros.h"
+
+#include <QtCore/QSharedPointer>
+
+QT_FORWARD_DECLARE_CLASS(QObject)
+
+class PYSIDETEST_API SharedPointerTestbench
+{
+public:
+ SharedPointerTestbench();
+
+ static QSharedPointer<int> createSharedPointerInt(int v);
+ static void printSharedPointerInt(const QSharedPointer<int> &p);
+
+ static QSharedPointer<QObject> createSharedPointerQObject();
+ static void printSharedPointerQObject(const QSharedPointer<QObject> &p);
+
+ static QSharedPointer<const QObject> createSharedPointerConstQObject();
+ static void printSharedPointerConstQObject(const QSharedPointer<const QObject> &p);
+
+};
+
+#endif // SHAREDPOINTERTESTBENCH_H
diff --git a/sources/pyside6/tests/pysidetest/signal_slot_warning.py b/sources/pyside6/tests/pysidetest/signal_slot_warning.py
index 67dce8084..b94281643 100644
--- a/sources/pyside6/tests/pysidetest/signal_slot_warning.py
+++ b/sources/pyside6/tests/pysidetest/signal_slot_warning.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
''' PYSIDE-315: https://bugreports.qt.io/browse/PYSIDE-315
Test that creating a signal in the wrong order triggers a warning. '''
diff --git a/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py b/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py
index 4e7bc1c3f..6025d119d 100644
--- a/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py
+++ b/sources/pyside6/tests/pysidetest/signal_tp_descr_get_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
"""
PYSIDE-68: Test that signals have a `__get__` function after all.
diff --git a/sources/pyside6/tests/pysidetest/signalandnamespace_test.py b/sources/pyside6/tests/pysidetest/signalandnamespace_test.py
index c84346928..3e91ca338 100644
--- a/sources/pyside6/tests/pysidetest/signalandnamespace_test.py
+++ b/sources/pyside6/tests/pysidetest/signalandnamespace_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/pysidetest/signalemissionfrompython_test.py b/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py
index 99c1a3e91..70c9e0082 100644
--- a/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py
+++ b/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py
@@ -1,33 +1,8 @@
#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#############################################################################
-##
-## 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$
-##
-#############################################################################
-
+import gc
import os
import sys
import unittest
@@ -56,6 +31,8 @@ class SignalEmissionFromPython(unittest.TestCase):
del self.obj2
del self.one_called
del self.two_called
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def testConnectNewStyleEmitVoidSignal(self):
def callbackOne():
diff --git a/sources/pyside6/tests/pysidetest/signalinstance_equality_test.py b/sources/pyside6/tests/pysidetest/signalinstance_equality_test.py
new file mode 100644
index 000000000..5faaa38d4
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/signalinstance_equality_test.py
@@ -0,0 +1,85 @@
+# 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 QFile, QObject, QTimer, Signal, SignalInstance, Slot
+from PySide6.QtWidgets import QSlider
+
+
+class C(QObject):
+ custom_signal = Signal()
+
+
+class D(C):
+ pass
+
+
+class TestSignalInstance(unittest.TestCase):
+ def test_signal_instances_are_equal(self):
+ o = QTimer()
+ self.assertTrue(o.timeout == o.timeout)
+
+ def test_inherited_signal_instances_are_equal(self):
+ o = QFile()
+ self.assertTrue(o.readyRead == o.readyRead)
+
+ def test_custom_signal_instances_are_equal(self):
+ o = C()
+ self.assertTrue(o.custom_signal == o.custom_signal)
+
+ def test_custom_inherited_signal_instances_are_equal(self):
+ o = D()
+ self.assertTrue(o.custom_signal == o.custom_signal)
+
+ # additional tests of old errors from 2010 or so
+ def test_uninitialized_SignalInstance(self):
+ # This will no longer crash
+ print(SignalInstance())
+ with self.assertRaises(RuntimeError):
+ SignalInstance().connect(lambda: None)
+ with self.assertRaises(RuntimeError):
+ SignalInstance().disconnect()
+ with self.assertRaises(RuntimeError):
+ SignalInstance().emit()
+
+
+class MyWidget(QSlider):
+ valueChanged = Signal(tuple)
+
+ def __init__(self):
+ super().__init__()
+ self.valueChanged.connect(self._on_change)
+
+ def setValue(self, value):
+ self.valueChanged.emit(value)
+
+ @Slot()
+ def _on_change(self, new_value):
+ print("new_value:", new_value)
+ global result
+ result = new_value
+
+
+class TestRightOrder(UsesQApplication):
+ def test_rightOrder(self):
+ wdg = MyWidget()
+
+ # PYSIDE-1751: Fixes the wrong behavior we got on >=6.2
+ # PySide <=6.1.3 prints "new_value: (30, 40)"
+ # PySide >=6.2 prints "new_value: 0"
+ wdg.setValue((30, 40))
+ self.assertEqual(result, (30, 40))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/signalwithdefaultvalue_test.py b/sources/pyside6/tests/pysidetest/signalwithdefaultvalue_test.py
index 458a87528..744b8c503 100644
--- a/sources/pyside6/tests/pysidetest/signalwithdefaultvalue_test.py
+++ b/sources/pyside6/tests/pysidetest/signalwithdefaultvalue_test.py
@@ -1,33 +1,8 @@
#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#############################################################################
-##
-## 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$
-##
-#############################################################################
-
+import gc
import os
import sys
import unittest
@@ -38,7 +13,7 @@ from init_paths import init_test_paths
init_test_paths(True)
from testbinding import TestObject
-from PySide6.QtCore import QObject, SIGNAL
+from PySide6.QtCore import Qt
'''Tests the behaviour of signals with default values.'''
@@ -54,6 +29,8 @@ class SignalWithDefaultValueTest(unittest.TestCase):
del self.obj
del self.void_called
del self.bool_called
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def testConnectNewStyleEmitVoidSignal(self):
def callbackVoid():
@@ -79,6 +56,17 @@ class SignalWithDefaultValueTest(unittest.TestCase):
self.assertTrue(self.void_called)
self.assertTrue(self.bool_called)
+ def testFlagsSignal(self):
+ test_value = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignBottom
+
+ def callbackAlignmentFlags(alignment):
+ self.alignment_flags_called = alignment
+
+ self.obj.flagsSignal.connect(callbackAlignmentFlags)
+ self.obj.emitFlagsSignal(test_value)
+ self.assertTrue(self.alignment_flags_called)
+ self.assertEqual(self.alignment_flags_called, test_value)
+
def testConnectOldStyleEmitVoidSignal(self):
def callbackVoid():
self.void_called = True
@@ -106,4 +94,3 @@ class SignalWithDefaultValueTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/pyside6/tests/pysidetest/snake_case_sub.py b/sources/pyside6/tests/pysidetest/snake_case_sub.py
new file mode 100644
index 000000000..4a482c35a
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/snake_case_sub.py
@@ -0,0 +1,23 @@
+# 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)
+
+"""
+PYSIDE-2029: Tests that snake_case is isolated from imported modules
+"""
+
+from PySide6.QtWidgets import QWidget
+
+
+def test_no_snake_case():
+ print(__name__)
+ widget = QWidget()
+ check = widget.sizeHint
diff --git a/sources/pyside6/tests/pysidetest/snake_case_test.py b/sources/pyside6/tests/pysidetest/snake_case_test.py
new file mode 100644
index 000000000..14e035773
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/snake_case_test.py
@@ -0,0 +1,38 @@
+# 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)
+
+"""
+PYSIDE-2029: Tests that snake_case is isolated from imported modules
+"""
+is_pypy = hasattr(sys, "pypy_version_info")
+
+from PySide6.QtCore import QSize
+from PySide6.QtWidgets import QWidget, QSpinBox
+if not is_pypy:
+ from __feature__ import snake_case
+from helper.usesqapplication import UsesQApplication
+
+import snake_case_sub
+
+@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy")
+class SnakeCaseNoPropagateTest(UsesQApplication):
+
+ def testSnakeCase(self):
+ # this worked
+ widget = QWidget()
+ check = widget.size_hint
+
+ snake_case_sub.test_no_snake_case()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/testobject.cpp b/sources/pyside6/tests/pysidetest/testobject.cpp
index 43fa93bac..fe4ec98f7 100644
--- a/sources/pyside6/tests/pysidetest/testobject.cpp
+++ b/sources/pyside6/tests/pysidetest/testobject.cpp
@@ -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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testobject.h"
@@ -55,6 +30,26 @@ void TestObject::emitSignalWithTypedefValue(int value)
emit signalWithTypedefValue(TypedefValue(value));
}
+void TestObject::emitSignalWithContainerTypedefValue(const IntList &il)
+{
+ emit signalWithContainerTypedefValue(il);
+}
+
+void TestObject::emitFlagsSignal(Qt::Alignment alignment)
+{
+ emit flagsSignal(alignment);
+}
+
+void TestObject::setQLatin1String(QLatin1String v)
+{
+ m_qLatin1String = v;
+}
+
+QString TestObject::qLatin1String() const
+{
+ return m_qLatin1String;
+}
+
QDebug operator<<(QDebug dbg, TestObject& testObject)
{
QDebugStateSaver saver(dbg);
diff --git a/sources/pyside6/tests/pysidetest/testobject.h b/sources/pyside6/tests/pysidetest/testobject.h
index 2795cec5c..a095a382e 100644
--- a/sources/pyside6/tests/pysidetest/testobject.h
+++ b/sources/pyside6/tests/pysidetest/testobject.h
@@ -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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TESTOBJECT_H
#define TESTOBJECT_H
@@ -33,12 +8,15 @@
#include <QtWidgets/QApplication>
+#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
QT_FORWARD_DECLARE_CLASS(QDebug)
+using IntList = QList<int>;
+
class IntValue
{
public:
@@ -48,16 +26,16 @@ public:
int value;
};
-typedef IntValue TypedefValue;
+using TypedefValue = IntValue;
class PYSIDETEST_API TestObject : public QObject
{
Q_OBJECT
public:
- static void createApp() { int argc=0; new QApplication(argc, 0); };
+ static void createApp() { int argc=0; new QApplication(argc, nullptr); };
static int checkType(const QVariant& var) { return var.metaType().id(); }
- TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {}
+ TestObject(int idValue, QObject* parent = nullptr) : QObject(parent), m_idValue(idValue) {}
int idValue() const { return m_idValue; }
static int staticMethodDouble(int value) { return value * 2; }
void addChild(QObject* c) { m_children.append(c); emit childrenChanged(m_children); }
@@ -69,6 +47,14 @@ public:
void emitSignalWithDefaultValue_bool();
void emitSignalWithTypedefValue(int value);
+ void emitSignalWithContainerTypedefValue(const IntList &il);
+
+ void emitFlagsSignal(Qt::Alignment alignment);
+
+ static constexpr auto LATIN1_TEST_FIELD = QLatin1StringView("test");
+
+ void setQLatin1String(QLatin1String v);
+ QString qLatin1String() const;
signals:
void idValue(int newValue);
@@ -77,16 +63,18 @@ signals:
void childrenChanged(const QList<QObject*>&);
void signalWithDefaultValue(bool value = false);
void signalWithTypedefValue(TypedefValue value);
+ void signalWithContainerTypedefValue(const IntList &il);
+ void flagsSignal(Qt::Alignment alignment);
private:
int m_idValue;
QList<QObject*> m_children;
+ QString m_qLatin1String;
};
PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject &testObject);
-typedef int PySideInt;
-
+using PySideInt = int;
namespace PySideCPP {
@@ -125,8 +113,7 @@ namespace PySideCPP2 {
enum Enum1 { Option1 = 1, Option2 = 2 };
-
-typedef long PySideLong;
+using PySideLong = long;
class PYSIDETEST_API TestObjectWithoutNamespace : public QObject
{
diff --git a/sources/pyside6/tests/pysidetest/testqvariantenum.cpp b/sources/pyside6/tests/pysidetest/testqvariantenum.cpp
new file mode 100644
index 000000000..7135e422a
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/testqvariantenum.cpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "testqvariantenum.h"
+
+QVariant TestQVariantEnum::getLValEnum() const
+{
+ return this->m_enum;
+}
+
+QVariant TestQVariantEnum::getRValEnum() const
+{
+ return QVariant(Qt::Orientation::Horizontal);
+}
+
+int TestQVariantEnum::getNumberFromQVarEnum(QVariant variantEnum)
+{
+ return variantEnum.toInt();
+}
+
+bool TestQVariantEnum::channelingEnum([[maybe_unused]] QVariant rvalEnum) const
+{
+ return false;
+}
+
+bool TestQVariantEnum::isEnumChanneled() const
+{
+ return this->channelingEnum(this->getRValEnum());
+}
diff --git a/sources/pyside6/tests/pysidetest/testqvariantenum.h b/sources/pyside6/tests/pysidetest/testqvariantenum.h
new file mode 100644
index 000000000..4b729e3dd
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/testqvariantenum.h
@@ -0,0 +1,35 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef TESTQVARIANT_H
+#define TESTQVARIANT_H
+
+#include "pysidetest_macros.h"
+
+#include <QtCore/QVariant>
+
+class PYSIDETEST_API TestQVariantEnum
+{
+public:
+ TestQVariantEnum(QVariant lvalue_enum) : m_enum(lvalue_enum) {}
+ QVariant getLValEnum() const;
+ static int getNumberFromQVarEnum(QVariant variantEnum = QVariant());
+ bool isEnumChanneled() const;
+ virtual QVariant getRValEnum() const;
+ virtual bool channelingEnum(QVariant rvalEnum) const;
+ virtual ~TestQVariantEnum() = default;
+private:
+ QVariant m_enum;
+};
+
+class PYSIDETEST_API QVariantHolder // modeled after Q3DParameter, test QVariant conversion
+{
+public:
+ void setValue(QVariant v) { m_variant = v; }
+ QVariant value() const { return m_variant; }
+
+private:
+ QVariant m_variant;
+};
+
+#endif // TESTQVARIANT_H
diff --git a/sources/pyside6/tests/pysidetest/testview.cpp b/sources/pyside6/tests/pysidetest/testview.cpp
index 110a87ac2..362239112 100644
--- a/sources/pyside6/tests/pysidetest/testview.cpp
+++ b/sources/pyside6/tests/pysidetest/testview.cpp
@@ -1,37 +1,12 @@
-/****************************************************************************
-**
-** 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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testview.h"
-#include <QDebug>
-#include <QWidget>
-#include <QAbstractListModel>
-#include <QAbstractItemDelegate>
+#include <QtCore/QDebug>
+#include <QtCore/QAbstractListModel>
+#include <QtWidgets/QAbstractItemDelegate>
+#include <QtWidgets/QWidget>
QVariant
TestView::getData()
@@ -43,7 +18,7 @@ TestView::getData()
QWidget*
TestView::getEditorWidgetFromItemDelegate() const
{
- if (!m_delegate)
+ if (m_delegate == nullptr)
return nullptr;
QModelIndex index;
diff --git a/sources/pyside6/tests/pysidetest/testview.h b/sources/pyside6/tests/pysidetest/testview.h
index b80a7fca9..746def83e 100644
--- a/sources/pyside6/tests/pysidetest/testview.h
+++ b/sources/pyside6/tests/pysidetest/testview.h
@@ -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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TESTVIEW_H
#define TESTVIEW_H
@@ -43,7 +18,8 @@ class PYSIDETEST_API TestView : public QObject
{
Q_OBJECT
public:
- TestView(QAbstractListModel* model, QObject* parent = 0) : QObject(parent), m_model(model) {}
+ TestView(QAbstractListModel* model, QObject* parent = nullptr) :
+ QObject(parent), m_model(model) {}
QAbstractListModel* model() { return m_model; }
QVariant getData();
@@ -52,7 +28,7 @@ public:
private:
QAbstractListModel* m_model;
- QAbstractItemDelegate* m_delegate;
+ QAbstractItemDelegate* m_delegate = nullptr;
};
#endif // TESTVIEW_H
diff --git a/sources/pyside6/tests/pysidetest/true_property_test.py b/sources/pyside6/tests/pysidetest/true_property_test.py
new file mode 100644
index 000000000..62f6505dc
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/true_property_test.py
@@ -0,0 +1,58 @@
+# 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)
+
+"""
+PYSIDE-2042: Tests true_property with inheritance
+"""
+is_pypy = hasattr(sys, "pypy_version_info")
+
+from PySide6.QtCore import QSize
+from PySide6.QtWidgets import QWidget, QSpinBox
+if not is_pypy:
+ from __feature__ import true_property
+from helper.usesqapplication import UsesQApplication
+
+
+@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy")
+class TruePropertyInheritanceTest(UsesQApplication):
+
+ def testTrueProperty(self):
+ # this worked
+ widget = QWidget()
+ check = widget.sizeHint
+ self.assertEqual(type(check), QSize)
+
+ # PYSIDE-2042: inheritance did not work
+ spin_box = QSpinBox()
+ check = spin_box.sizeHint
+ self.assertEqual(type(check), QSize)
+
+ def testHiddenMethods(self):
+ # PYSIDE-1889: setVisible is no longer a meta function but comes from the Property
+ widget = QWidget()
+ self.assertTrue("visible" in QWidget.__dict__)
+ self.assertFalse("isVisible" in QWidget.__dict__)
+ self.assertFalse("setVisible" in QWidget.__dict__)
+ self.assertTrue(hasattr(widget, "isVisible"))
+ self.assertTrue(hasattr(widget, "setVisible"))
+ self.assertEqual(widget.isVisible, QWidget.visible.fget)
+ self.assertEqual(widget.setVisible, QWidget.visible.fset)
+
+ # This works with inheritance as well:
+ class SubClass(QWidget):
+ pass
+ sub_widget = SubClass()
+ self.assertEqual(sub_widget.isVisible, QWidget.visible.fget)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/typedef_signal_test.py b/sources/pyside6/tests/pysidetest/typedef_signal_test.py
index 714695823..d0bdc880b 100644
--- a/sources/pyside6/tests/pysidetest/typedef_signal_test.py
+++ b/sources/pyside6/tests/pysidetest/typedef_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
import os
import sys
@@ -35,7 +10,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(True)
-from PySide6.QtCore import QObject
+from PySide6.QtCore import QObject, Slot
from testbinding import TestObject
@@ -48,6 +23,10 @@ class Receiver(QObject):
def slot(self, value):
self.received = value
+ @Slot("IntList")
+ def containerSlot(self, value):
+ self.received = value
+
class TypedefSignal(unittest.TestCase):
@@ -59,6 +38,15 @@ class TypedefSignal(unittest.TestCase):
obj.emitSignalWithTypedefValue(2)
self.assertEqual(receiver.received.value, 2)
+ def testContainerTypedef(self):
+ obj = TestObject(0)
+ receiver = Receiver()
+
+ test_list = [1, 2]
+ obj.signalWithContainerTypedefValue.connect(receiver.containerSlot)
+ obj.emitSignalWithContainerTypedefValue(test_list)
+ self.assertEqual(receiver.received, test_list)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/pysidetest/typesystem_pysidetest.xml b/sources/pyside6/tests/pysidetest/typesystem_pysidetest.xml
index 2736f8319..592d90a83 100644
--- a/sources/pyside6/tests/pysidetest/typesystem_pysidetest.xml
+++ b/sources/pyside6/tests/pysidetest/typesystem_pysidetest.xml
@@ -63,17 +63,18 @@
</modify-function>
</object-type>
+ <value-type name="TestQVariantEnum"/>
+
<namespace-type name="FlagsNamespace" visible="no">
<enum-type name="Option" flags="Options"/>
<object-type name="ClassForEnum" />
</namespace-type>
- <suppress-warning text="type 'QPyTextObject' is specified in typesystem, but not defined. This could potentially lead to compilation errors." />
- <!-- Qt5: I never really understood this warning. Probably it is because there
- is no way to instantiate the class. Anyway, why must this class emit this warning?
- I am not a C++ warrior, so I'd prefer if it would say "it is ok if you see this warning!".
- Well, maybe somebody will enlighten me, and I'll change this comment.
- I'd actually prefer an implementation that avoids generating this message, but I still failed
- doing so :-(
- -->
+ <object-type name="SharedPointerTestbench"/>
+
+ <value-type name="QVariantHolder"/>
+
+ <smart-pointer-type name="QSharedPointer" type="shared" getter="data"
+ reset-method="reset"/>
+
</typesystem>
diff --git a/sources/pyside6/tests/pysidetest/version_test.py b/sources/pyside6/tests/pysidetest/version_test.py
index 397e61a68..f47ffc6d0 100644
--- a/sources/pyside6/tests/pysidetest/version_test.py
+++ b/sources/pyside6/tests/pysidetest/version_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