blob: d9250a9e0ac8d9dd3911c62595e16b9d4ae52ea5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()
|