aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/util/helper/timedqapplication.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/util/helper/timedqapplication.py')
-rw-r--r--sources/pyside6/tests/util/helper/timedqapplication.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/pyside6/tests/util/helper/timedqapplication.py b/sources/pyside6/tests/util/helper/timedqapplication.py
new file mode 100644
index 000000000..d9250a9e0
--- /dev/null
+++ b/sources/pyside6/tests/util/helper/timedqapplication.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+'''Helper classes and functions'''
+
+import gc
+import unittest
+
+from PySide6.QtCore import QTimer
+from PySide6.QtWidgets import QApplication
+
+
+class TimedQApplication(unittest.TestCase):
+ '''Helper class with timed QApplication exec loop'''
+
+ def setUp(self, timeout=100):
+ '''Setups this Application.
+
+ timeout - timeout in milisseconds'''
+ self.app = QApplication.instance() or QApplication([])
+ 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()