diff options
author | Friedemann Kleint <[email protected]> | 2021-12-01 08:07:09 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2021-12-01 09:27:35 +0100 |
commit | ac4431fcc71f01cde9bd1fd885d42960b869c924 (patch) | |
tree | 6150d12ac616885ca66ee0193dd591ce6f6174aa /sources/pyside6/tests/util/helper | |
parent | c94bc617282e0834ee71692e876d96d9d7ee7012 (diff) |
tests: Add TimedQGuiApplication
It is sufficient for Gui and QML tests.
Pick-to: 6.2
Change-Id: I6302c3d3f016fb95914f1754e794883cad69bce2
Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Diffstat (limited to 'sources/pyside6/tests/util/helper')
-rw-r--r-- | sources/pyside6/tests/util/helper/timedqguiapplication.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/sources/pyside6/tests/util/helper/timedqguiapplication.py b/sources/pyside6/tests/util/helper/timedqguiapplication.py new file mode 100644 index 000000000..b2215b4a2 --- /dev/null +++ b/sources/pyside6/tests/util/helper/timedqguiapplication.py @@ -0,0 +1,52 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +'''Helper classes and functions''' + +import gc +import unittest + +from PySide6.QtCore import QTimer +from PySide6.QtGui import QGuiApplication + + +class TimedQGuiApplication(unittest.TestCase): + '''Helper class with timed QGuiApplication exec loop''' + + def setUp(self, timeout=100): + '''Sets up this Application. + + timeout - timeout in millisseconds''' + self.app = QGuiApplication.instance() or QGuiApplication([]) + QTimer.singleShot(timeout, self.app.quit) + + def tearDown(self): + '''Delete resources''' + del self.app + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() |