Skip to content

Commit d42ba1c

Browse files
committed
tests: Simplify Timer utility class
After enabling -Werror for tests, for unknown reasons, tests/test_wait_signal.py::test_zero_timeout[True] consistently fails on macOS + Python 3.13 + PySide6 (only there!) with: RuntimeWarning: Failed to disconnect (functools.partial(<bound method timer.<locals>.Timer._emit of <conftest.Timer(0x...) at 0x...>>, <PySide6.QtCore.SignalInstance signal() at 0x...>)) from signal "timeout()". Qt supports connecting signals to signals, so we can save the detour via Python and functools.partial.
1 parent 965ccaa commit d42ba1c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tests/conftest.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import functools
21
import time
32

43
import pytest
@@ -63,10 +62,9 @@ def shutdown(self):
6362
def single_shot(self, signal, delay):
6463
t = qt_api.QtCore.QTimer(self)
6564
t.setSingleShot(True)
66-
slot = functools.partial(self._emit, signal)
67-
t.timeout.connect(slot)
65+
t.timeout.connect(signal)
6866
t.start(delay)
69-
self.timers_and_slots.append((t, slot))
67+
self.timers_and_slots.append((t, signal))
7068

7169
def single_shot_callback(self, callback, delay):
7270
t = qt_api.QtCore.QTimer(self)
@@ -75,9 +73,6 @@ def single_shot_callback(self, callback, delay):
7573
t.start(delay)
7674
self.timers_and_slots.append((t, callback))
7775

78-
def _emit(self, signal):
79-
signal.emit()
80-
8176
timer = Timer()
8277
yield timer
8378
timer.shutdown()

0 commit comments

Comments
 (0)