aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-02-13 13:35:03 +0100
committerChristian Tismer <tismer@stackless.com>2020-02-21 15:14:18 +0100
commitd579912b31d7cfa7b0b216916fbbf3eb632a9d9d (patch)
tree0e206543adc1781003c39bdf8627af09cbe9270f /sources/pyside2/tests
parentf69d163d17d3717c28f2c065173113756d7c50ef (diff)
Turn qApp into a normal Python variable, finally
After a long odyssey of more or less unpythonic compromizes, the qApp "macro" would finally be moved into a normal variable without surprizes. This was only possible since we removed qApp from QtWidgets and other modules. Otherwise, from PySide2.QtWidgets import * would pull qApp, being the constant "None", into main and shadow the true qApp variable in the builtins. By inserting qApp into the builtins, only, we make sure that this variable is always freshly looked up, without making it change its contents. DONE... + change the singleton code to normal + rename to MakeQAppWrapper + simplify the implementation + fix new bug concerning duplicate applications + check very much for refcounting bugs + review the rest of the implementation and further simplify Note... The Q*Application variable will not be turned back into a GC variable. This is not worth the effort. Fixes: PYSIDE-571 Change-Id: Idbd158c083318e6b0dfe48d62485c68c90e944de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtWidgets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_750.py2
-rw-r--r--sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py39
-rw-r--r--sources/pyside2/tests/pysidetest/qapp_like_a_macro_test.py15
4 files changed, 6 insertions, 51 deletions
diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
index 6d8645918..6682136ea 100644
--- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt
+++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
@@ -87,7 +87,6 @@ PYSIDE_TEST(qapp_issue_585.py)
PYSIDE_TEST(qapp_test.py)
PYSIDE_TEST(qapplication_test.py)
PYSIDE_TEST(qapplication_exit_segfault_test.py)
-PYSIDE_TEST(qapplication_singleton_test.py)
PYSIDE_TEST(qbrush_test.py)
PYSIDE_TEST(qdynamic_signal.py)
# TODO: This passes, but requires manual button clicking (at least on mac)
diff --git a/sources/pyside2/tests/QtWidgets/bug_750.py b/sources/pyside2/tests/QtWidgets/bug_750.py
index 42b6c9843..78d333efd 100644
--- a/sources/pyside2/tests/QtWidgets/bug_750.py
+++ b/sources/pyside2/tests/QtWidgets/bug_750.py
@@ -36,7 +36,7 @@ from helper.usesqapplication import UsesQApplication
from PySide2.QtCore import QTimer
from PySide2.QtGui import QPainter, QFont, QFontInfo
-from PySide2.QtWidgets import QWidget, qApp
+from PySide2.QtWidgets import QWidget
class MyWidget(QWidget):
def paintEvent(self, e):
diff --git a/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py b/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py
deleted file mode 100644
index e79e303f0..000000000
--- a/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py
+++ /dev/null
@@ -1,39 +0,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 unittest
-
-from PySide2.QtWidgets import QApplication
-
-class TestSingleton(unittest.TestCase):
- def testBasic(self):
- a = QApplication([])
- self.assertRaises(RuntimeError, QApplication, [])
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/qapp_like_a_macro_test.py b/sources/pyside2/tests/pysidetest/qapp_like_a_macro_test.py
index 43f455ea9..2cc18c9c9 100644
--- a/sources/pyside2/tests/pysidetest/qapp_like_a_macro_test.py
+++ b/sources/pyside2/tests/pysidetest/qapp_like_a_macro_test.py
@@ -32,6 +32,8 @@ import PySide2
# This test tests the new "macro" feature of qApp.
# It also uses the qApp variable to finish the instance and start over.
+# Note: this test makes qapplication_singleton_test.py obsolete.
+
class qAppMacroTest(unittest.TestCase):
_test_1093_is_first = True
@@ -44,13 +46,8 @@ class qAppMacroTest(unittest.TestCase):
QtWidgets = QtGui = QtCore
# qApp is in the builtins
self.assertEqual(bool(qApp), False)
- # and also in certain PySide modules
- QtCore.qApp, QtGui.qApp, QtWidgets.qApp
- # and they are all the same
- self.assertTrue(qApp is QtCore.qApp is QtGui.qApp is QtWidgets.qApp)
- # and the type is NoneType, but it is not None (cannot work)
- self.assertTrue(type(qApp) is type(None))
- self.assertTrue(qApp is not None)
+ # and the type is None
+ self.assertTrue(qApp is None)
# now we create an application for all cases
classes = (QtCore.QCoreApplication,
QtGui.QGuiApplication,
@@ -63,9 +60,7 @@ class qAppMacroTest(unittest.TestCase):
QtCore.QCoreApplication([])
with self.assertRaises(RuntimeError):
QtCore.QCoreApplication([])
- self.assertEqual(QtCore.QCoreApplication.instance(), QtCore.qApp)
- # and they are again all the same
- self.assertTrue(qApp is QtCore.qApp is QtGui.qApp is QtWidgets.qApp)
+ self.assertEqual(QtCore.QCoreApplication.instance(), qApp)
def test_1093(self):
# Test that without creating a QApplication staticMetaObject still exists.