blob: b495eaead8ba060fbc5c6ea89d1d8d7c7d9a4c3e (
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
28
29
30
31
32
33
34
|
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
from __future__ import annotations
import gc
class BasicPySlotCase:
'''Base class that tests python slots and signal emissions.
Python slots are defined as any callable passed to QObject.connect().
'''
def setUp(self):
self.called = False
def tearDown(self):
try:
del self.args
except:
pass
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
gc.collect()
def cb(self, *args):
'''Simple callback with arbitrary arguments.
The test function must setup the 'args' attribute with a sequence
containing the arguments expected to be received by this slot.
Currently only a single connection is supported.
'''
if tuple(self.args) == args:
self.called = True
else:
raise ValueError('Invalid arguments for callback')
|