diff options
Diffstat (limited to 'sources/pyside2/tests/signals')
42 files changed, 376 insertions, 33 deletions
diff --git a/sources/pyside2/tests/signals/CMakeLists.txt b/sources/pyside2/tests/signals/CMakeLists.txt index fe06a3430..740319f39 100644 --- a/sources/pyside2/tests/signals/CMakeLists.txt +++ b/sources/pyside2/tests/signals/CMakeLists.txt @@ -28,6 +28,7 @@ PYSIDE_TEST(short_circuit_test.py) PYSIDE_TEST(signal2signal_connect_test.py) PYSIDE_TEST(signal_autoconnect_test.py) PYSIDE_TEST(signal_connectiontype_support_test.py) +PYSIDE_TEST(signal_enum_test.py) PYSIDE_TEST(signal_emission_gui_test.py) PYSIDE_TEST(signal_emission_test.py) PYSIDE_TEST(signal_func_test.py) diff --git a/sources/pyside2/tests/signals/args_dont_match_test.py b/sources/pyside2/tests/signals/args_dont_match_test.py index f50611ad6..732706ac0 100644 --- a/sources/pyside2/tests/signals/args_dont_match_test.py +++ b/sources/pyside2/tests/signals/args_dont_match_test.py @@ -28,7 +28,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * class ArgsDontMatch(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/bug_189.py b/sources/pyside2/tests/signals/bug_189.py index 51810b66c..6492f0359 100644 --- a/sources/pyside2/tests/signals/bug_189.py +++ b/sources/pyside2/tests/signals/bug_189.py @@ -26,10 +26,16 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2 import QtCore, QtWidgets -from helper import UsesQApplication +from helper.usesqapplication import UsesQApplication class TestBugPYSIDE189(UsesQApplication): diff --git a/sources/pyside2/tests/signals/bug_311.py b/sources/pyside2/tests/signals/bug_311.py index 2f77bb973..c9782741d 100644 --- a/sources/pyside2/tests/signals/bug_311.py +++ b/sources/pyside2/tests/signals/bug_311.py @@ -29,9 +29,16 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2 import QtCore -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class DerivedDate(QtCore.QDate): def __init__(self,y,m,d): diff --git a/sources/pyside2/tests/signals/bug_312.py b/sources/pyside2/tests/signals/bug_312.py index 08019654c..1b6eabe7e 100644 --- a/sources/pyside2/tests/signals/bug_312.py +++ b/sources/pyside2/tests/signals/bug_312.py @@ -29,8 +29,14 @@ ## ############################################################################# -import unittest +import os import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL MAX_LOOPS = 5 diff --git a/sources/pyside2/tests/signals/bug_319.py b/sources/pyside2/tests/signals/bug_319.py index 7210af072..17cd8abcf 100644 --- a/sources/pyside2/tests/signals/bug_319.py +++ b/sources/pyside2/tests/signals/bug_319.py @@ -29,9 +29,16 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2 import QtCore -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class Listener(QtCore.QObject): def __init__(self): diff --git a/sources/pyside2/tests/signals/bug_79.py b/sources/pyside2/tests/signals/bug_79.py index 9eb783d77..ca25fb3f4 100644 --- a/sources/pyside2/tests/signals/bug_79.py +++ b/sources/pyside2/tests/signals/bug_79.py @@ -27,9 +27,14 @@ ############################################################################# from __future__ import print_function -import unittest -import sys +import os import gc +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) from PySide2 import QtGui, QtWidgets @@ -56,13 +61,15 @@ class ConnectTest(unittest.TestCase): # if this is no debug build, then we check at least that # we do not crash any longer. if not skiptest: - total = sys.gettotalrefcount() + total = gettotalrefcount() for idx in range(1000): o.selectionModel().destroyed.connect(self.callback) o.selectionModel().destroyed.disconnect(self.callback) gc.collect() if not skiptest: - self.assertTrue(abs(gettotalrefcount() - total) < 10) + delta = gettotalrefcount() - total + print("delta total refcount =", delta) + self.assertTrue(abs(delta) < 10) if __name__ == '__main__': diff --git a/sources/pyside2/tests/signals/decorators_test.py b/sources/pyside2/tests/signals/decorators_test.py index e5a8be461..e262f0bce 100644 --- a/sources/pyside2/tests/signals/decorators_test.py +++ b/sources/pyside2/tests/signals/decorators_test.py @@ -28,8 +28,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, Slot, SIGNAL, SLOT class MyObject(QObject): diff --git a/sources/pyside2/tests/signals/disconnect_test.py b/sources/pyside2/tests/signals/disconnect_test.py index 79c33ed7a..6242e9e38 100644 --- a/sources/pyside2/tests/signals/disconnect_test.py +++ b/sources/pyside2/tests/signals/disconnect_test.py @@ -26,10 +26,14 @@ ## ############################################################################# -import os, sys -sys.path.insert(0, os.path.join("..", "pysidetest")) - +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(True) + from PySide2.QtCore import * from testbinding import TestObject diff --git a/sources/pyside2/tests/signals/invalid_callback_test.py b/sources/pyside2/tests/signals/invalid_callback_test.py index b3b301d67..442720baa 100644 --- a/sources/pyside2/tests/signals/invalid_callback_test.py +++ b/sources/pyside2/tests/signals/invalid_callback_test.py @@ -28,8 +28,14 @@ '''Test cases for passing invalid callbacks to QObject.connect''' +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL class InvalidCallback(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/lambda_gui_test.py b/sources/pyside2/tests/signals/lambda_gui_test.py index f6eb7b364..843b4037f 100644 --- a/sources/pyside2/tests/signals/lambda_gui_test.py +++ b/sources/pyside2/tests/signals/lambda_gui_test.py @@ -28,8 +28,14 @@ '''Connecting lambda to gui signals''' +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL try: @@ -38,7 +44,7 @@ try: except ImportError: hasQtGui = False -from helper import UsesQApplication +from helper.usesqapplication import UsesQApplication if hasQtGui: class Control: diff --git a/sources/pyside2/tests/signals/lambda_test.py b/sources/pyside2/tests/signals/lambda_test.py index c22674fcc..f01096150 100644 --- a/sources/pyside2/tests/signals/lambda_test.py +++ b/sources/pyside2/tests/signals/lambda_test.py @@ -30,12 +30,17 @@ '''Connecting lambda to signals''' +import os import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, QProcess -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class Dummy(QObject): diff --git a/sources/pyside2/tests/signals/leaking_signal_test.py b/sources/pyside2/tests/signals/leaking_signal_test.py index f8ac041ba..705d16075 100644 --- a/sources/pyside2/tests/signals/leaking_signal_test.py +++ b/sources/pyside2/tests/signals/leaking_signal_test.py @@ -26,10 +26,18 @@ ## ############################################################################# +import os +import sys import unittest -from PySide2 import QtCore import weakref +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide2 import QtCore + + class LeakingSignal(unittest.TestCase): def testLeakingSignal(self): diff --git a/sources/pyside2/tests/signals/multiple_connections_gui_test.py b/sources/pyside2/tests/signals/multiple_connections_gui_test.py index a80f6277c..4429c49f4 100644 --- a/sources/pyside2/tests/signals/multiple_connections_gui_test.py +++ b/sources/pyside2/tests/signals/multiple_connections_gui_test.py @@ -26,9 +26,15 @@ ## ############################################################################# -import unittest -import random from functools import partial +import os +import random +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) from PySide2.QtCore import QObject, SIGNAL @@ -38,7 +44,8 @@ try: except ImportError: hasQtGui = False -from helper import BasicPySlotCase, UsesQApplication +from helper.basicpyslotcase import BasicPySlotCase +from helper.usesqapplication import UsesQApplication class MultipleSignalConnections(unittest.TestCase): '''Base class for multiple signal connection testing''' diff --git a/sources/pyside2/tests/signals/multiple_connections_test.py b/sources/pyside2/tests/signals/multiple_connections_test.py index 2ce780e4e..a8f5bcd9d 100644 --- a/sources/pyside2/tests/signals/multiple_connections_test.py +++ b/sources/pyside2/tests/signals/multiple_connections_test.py @@ -26,13 +26,19 @@ ## ############################################################################# +from functools import partial +import os import sys import unittest -from functools import partial + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) from PySide2.QtCore import QObject, SIGNAL, QProcess -from helper import BasicPySlotCase, UsesQCoreApplication +from helper.basicpyslotcase import BasicPySlotCase +from helper.usesqcoreapplication import UsesQCoreApplication class MultipleSignalConnections(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/pysignal_test.py b/sources/pyside2/tests/signals/pysignal_test.py index a5f2d8c5e..5561671c4 100644 --- a/sources/pyside2/tests/signals/pysignal_test.py +++ b/sources/pyside2/tests/signals/pysignal_test.py @@ -26,7 +26,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, SLOT, Qt try: @@ -35,7 +42,7 @@ try: except ImportError: hasQtGui = False -from helper import UsesQApplication +from helper.usesqapplication import UsesQApplication class Dummy(QObject): """Dummy class used in this test.""" diff --git a/sources/pyside2/tests/signals/qobject_destroyed_test.py b/sources/pyside2/tests/signals/qobject_destroyed_test.py index 87e78c22c..35752a6ca 100644 --- a/sources/pyside2/tests/signals/qobject_destroyed_test.py +++ b/sources/pyside2/tests/signals/qobject_destroyed_test.py @@ -26,8 +26,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL class QObjectDestroyed(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/qobject_receivers_test.py b/sources/pyside2/tests/signals/qobject_receivers_test.py index 629fda5cf..8ad89fe78 100644 --- a/sources/pyside2/tests/signals/qobject_receivers_test.py +++ b/sources/pyside2/tests/signals/qobject_receivers_test.py @@ -30,7 +30,14 @@ ''' Test case for QObject.receivers()''' +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * def cute_slot(): diff --git a/sources/pyside2/tests/signals/qobject_sender_test.py b/sources/pyside2/tests/signals/qobject_sender_test.py index 432450bb8..ce11b803a 100644 --- a/sources/pyside2/tests/signals/qobject_sender_test.py +++ b/sources/pyside2/tests/signals/qobject_sender_test.py @@ -31,9 +31,16 @@ '''Test cases for QObject.sender()''' +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class ExtQTimer(QTimer): def __init__(self): diff --git a/sources/pyside2/tests/signals/ref01_test.py b/sources/pyside2/tests/signals/ref01_test.py index e12dfc910..d2c658568 100644 --- a/sources/pyside2/tests/signals/ref01_test.py +++ b/sources/pyside2/tests/signals/ref01_test.py @@ -29,7 +29,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, Signal class BoundAndUnboundSignalsTest(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/ref02_test.py b/sources/pyside2/tests/signals/ref02_test.py index 5449d6afa..9a31b4b52 100644 --- a/sources/pyside2/tests/signals/ref02_test.py +++ b/sources/pyside2/tests/signals/ref02_test.py @@ -29,9 +29,16 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QCoreApplication, QTimeLine -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class NativeSignalsTest(UsesQCoreApplication): diff --git a/sources/pyside2/tests/signals/ref03_test.py b/sources/pyside2/tests/signals/ref03_test.py index da24da659..25f404f38 100644 --- a/sources/pyside2/tests/signals/ref03_test.py +++ b/sources/pyside2/tests/signals/ref03_test.py @@ -29,8 +29,15 @@ ## ############################################################################# -import unittest +import os +import sys from sys import getrefcount +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject class DisconnectSignalsTest(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/ref04_test.py b/sources/pyside2/tests/signals/ref04_test.py index 033449cc7..4c66c04ef 100644 --- a/sources/pyside2/tests/signals/ref04_test.py +++ b/sources/pyside2/tests/signals/ref04_test.py @@ -29,7 +29,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, Signal class ExtQObject(QObject): diff --git a/sources/pyside2/tests/signals/ref05_test.py b/sources/pyside2/tests/signals/ref05_test.py index 9bc299332..3b7bf1983 100644 --- a/sources/pyside2/tests/signals/ref05_test.py +++ b/sources/pyside2/tests/signals/ref05_test.py @@ -29,9 +29,16 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, QCoreApplication, QTimeLine, Slot -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class ExtQObject(QObject): diff --git a/sources/pyside2/tests/signals/ref06_test.py b/sources/pyside2/tests/signals/ref06_test.py index a5b26b393..51d78e638 100644 --- a/sources/pyside2/tests/signals/ref06_test.py +++ b/sources/pyside2/tests/signals/ref06_test.py @@ -29,9 +29,16 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, QCoreApplication, QTimeLine, Signal, Slot -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class ExtQObject(QObject): signalbetween = Signal('qreal') diff --git a/sources/pyside2/tests/signals/segfault_proxyparent_test.py b/sources/pyside2/tests/signals/segfault_proxyparent_test.py index 758c7888f..2d45f1e7f 100644 --- a/sources/pyside2/tests/signals/segfault_proxyparent_test.py +++ b/sources/pyside2/tests/signals/segfault_proxyparent_test.py @@ -26,8 +26,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL # Description of the problem diff --git a/sources/pyside2/tests/signals/self_connect_test.py b/sources/pyside2/tests/signals/self_connect_test.py index ee84a75c5..cca97b096 100644 --- a/sources/pyside2/tests/signals/self_connect_test.py +++ b/sources/pyside2/tests/signals/self_connect_test.py @@ -30,12 +30,18 @@ '''Using self.connect(signal, method)''' +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, SLOT from PySide2.QtWidgets import QPushButton, QWidget -from helper import UsesQApplication +from helper.usesqapplication import UsesQApplication class SelfConnect(UsesQApplication): diff --git a/sources/pyside2/tests/signals/short_circuit_test.py b/sources/pyside2/tests/signals/short_circuit_test.py index e181b6497..61acc77c0 100644 --- a/sources/pyside2/tests/signals/short_circuit_test.py +++ b/sources/pyside2/tests/signals/short_circuit_test.py @@ -26,8 +26,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, SLOT class Dummy(QObject): diff --git a/sources/pyside2/tests/signals/signal2signal_connect_test.py b/sources/pyside2/tests/signals/signal2signal_connect_test.py index 4619a8694..c5008c942 100644 --- a/sources/pyside2/tests/signals/signal2signal_connect_test.py +++ b/sources/pyside2/tests/signals/signal2signal_connect_test.py @@ -30,7 +30,14 @@ ''' Test case for signal to signal connections.''' +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * def cute_slot(): diff --git a/sources/pyside2/tests/signals/signal_autoconnect_test.py b/sources/pyside2/tests/signals/signal_autoconnect_test.py index 9fe8f94d3..b19f28ab7 100644 --- a/sources/pyside2/tests/signals/signal_autoconnect_test.py +++ b/sources/pyside2/tests/signals/signal_autoconnect_test.py @@ -28,8 +28,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * from PySide2.QtWidgets import * diff --git a/sources/pyside2/tests/signals/signal_connectiontype_support_test.py b/sources/pyside2/tests/signals/signal_connectiontype_support_test.py index d8dee9454..00865a95e 100644 --- a/sources/pyside2/tests/signals/signal_connectiontype_support_test.py +++ b/sources/pyside2/tests/signals/signal_connectiontype_support_test.py @@ -26,8 +26,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, Qt class Dummy(QObject): diff --git a/sources/pyside2/tests/signals/signal_emission_gui_test.py b/sources/pyside2/tests/signals/signal_emission_gui_test.py index a357b1536..d46e78c5e 100644 --- a/sources/pyside2/tests/signals/signal_emission_gui_test.py +++ b/sources/pyside2/tests/signals/signal_emission_gui_test.py @@ -30,8 +30,14 @@ """Tests covering signal emission and receiving to python slots""" +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, SLOT try: @@ -40,7 +46,8 @@ try: except ImportError: hasQtGui = False -from helper import BasicPySlotCase, UsesQApplication +from helper.basicpyslotcase import BasicPySlotCase +from helper.usesqapplication import UsesQApplication if hasQtGui: class ButtonPySlot(UsesQApplication, BasicPySlotCase): diff --git a/sources/pyside2/tests/signals/signal_emission_test.py b/sources/pyside2/tests/signals/signal_emission_test.py index d4f17700b..f9c221e8f 100644 --- a/sources/pyside2/tests/signals/signal_emission_test.py +++ b/sources/pyside2/tests/signals/signal_emission_test.py @@ -30,13 +30,19 @@ """Tests covering signal emission and receiving to python slots""" +import functools +import os import sys import unittest -import functools + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) from PySide2.QtCore import QObject, SIGNAL, SLOT, QProcess, QTimeLine -from helper import BasicPySlotCase, UsesQCoreApplication +from helper.basicpyslotcase import BasicPySlotCase +from helper.usesqcoreapplication import UsesQCoreApplication class ArgsOnEmptySignal(UsesQCoreApplication): diff --git a/sources/pyside2/tests/signals/signal_enum_test.py b/sources/pyside2/tests/signals/signal_enum_test.py new file mode 100644 index 000000000..3a24b919d --- /dev/null +++ b/sources/pyside2/tests/signals/signal_enum_test.py @@ -0,0 +1,82 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from init_paths import init_test_paths +init_test_paths(False) + +from PySide2.QtCore import QObject, Signal, Slot +import py3kcompat as py3k + + +if py3k.IS_PY3K: + from enum import Enum + + class Colors(Enum): + red = 1 + green = 2 + blue = 3 + + class Obj(QObject): + enum_signal = Signal(Colors) + object_signal = Signal(object) + + def __init__(self, parent=None): + QObject.__init__(self, parent) + self.enum_signal.connect(self.get_result) + self.object_signal.connect(self.get_result) + self.value = -1 + + @Slot() + def get_result(self, i): + self.value = i + + + class SignalEnumTests(unittest.TestCase): + '''Test Signal with enum.Enum''' + + def testSignal(self): + o = Obj() + # Default value + self.assertEqual(o.value, -1) + + # Enum Signal + o.enum_signal.emit(Colors.green) + self.assertEqual(o.value, Colors.green) + + # object Signal + o.object_signal.emit(Colors.red) + self.assertEqual(o.value, Colors.red) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/signals/signal_func_test.py b/sources/pyside2/tests/signals/signal_func_test.py index 37bb191fe..0026bc726 100644 --- a/sources/pyside2/tests/signals/signal_func_test.py +++ b/sources/pyside2/tests/signals/signal_func_test.py @@ -28,8 +28,14 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import SIGNAL, SLOT class SIGNALSLOTTests(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/signal_manager_refcount_test.py b/sources/pyside2/tests/signals/signal_manager_refcount_test.py index ece9a3ce0..6942f983d 100644 --- a/sources/pyside2/tests/signals/signal_manager_refcount_test.py +++ b/sources/pyside2/tests/signals/signal_manager_refcount_test.py @@ -28,8 +28,16 @@ ## ############################################################################# + +import os +import sys from sys import getrefcount import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL class SignalManagerRefCount(unittest.TestCase): diff --git a/sources/pyside2/tests/signals/signal_number_limit_test.py b/sources/pyside2/tests/signals/signal_number_limit_test.py index ba1edac25..67bb63e44 100644 --- a/sources/pyside2/tests/signals/signal_number_limit_test.py +++ b/sources/pyside2/tests/signals/signal_number_limit_test.py @@ -29,7 +29,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2 import QtCore class Emitter(QtCore.QObject): diff --git a/sources/pyside2/tests/signals/signal_object_test.py b/sources/pyside2/tests/signals/signal_object_test.py index ab9522b13..bf4abedbc 100644 --- a/sources/pyside2/tests/signals/signal_object_test.py +++ b/sources/pyside2/tests/signals/signal_object_test.py @@ -28,10 +28,16 @@ ## ############################################################################# +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QTimer, Signal, QObject, Slot, Qt -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class MyObject(QTimer): sig1 = Signal() diff --git a/sources/pyside2/tests/signals/signal_signature_test.py b/sources/pyside2/tests/signals/signal_signature_test.py index 191f209a8..1f661de0a 100644 --- a/sources/pyside2/tests/signals/signal_signature_test.py +++ b/sources/pyside2/tests/signals/signal_signature_test.py @@ -30,9 +30,16 @@ '''Test case for signal signature received by QObject::connectNotify().''' +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication called = False name = "Old" diff --git a/sources/pyside2/tests/signals/signal_with_primitive_type_test.py b/sources/pyside2/tests/signals/signal_with_primitive_type_test.py index cc3f084d0..f7f691f34 100644 --- a/sources/pyside2/tests/signals/signal_with_primitive_type_test.py +++ b/sources/pyside2/tests/signals/signal_with_primitive_type_test.py @@ -28,7 +28,14 @@ ## ############################################################################# +import os +import sys import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import * diff --git a/sources/pyside2/tests/signals/slot_reference_count_test.py b/sources/pyside2/tests/signals/slot_reference_count_test.py index e6bcda0e8..7885a358b 100644 --- a/sources/pyside2/tests/signals/slot_reference_count_test.py +++ b/sources/pyside2/tests/signals/slot_reference_count_test.py @@ -28,8 +28,14 @@ ''' Forced disconnection: Delete one end of the signal connection''' -import unittest +import os +import sys from sys import getrefcount +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) from PySide2.QtCore import QObject, SIGNAL, SLOT diff --git a/sources/pyside2/tests/signals/static_metaobject_test.py b/sources/pyside2/tests/signals/static_metaobject_test.py index b66610f38..bdb3b1992 100644 --- a/sources/pyside2/tests/signals/static_metaobject_test.py +++ b/sources/pyside2/tests/signals/static_metaobject_test.py @@ -30,10 +30,16 @@ """Tests covering signal emission and receiving to python slots""" +import os +import sys import unittest +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + from PySide2.QtCore import QObject, SIGNAL, Slot -from helper import UsesQCoreApplication +from helper.usesqcoreapplication import UsesQCoreApplication class MyObject(QObject): def __init__(self, parent=None): |