diff --git a/orangecanvas/utils/tests/test_overlay.py b/orangecanvas/utils/tests/test_overlay.py index 4deae4bb..393f565c 100644 --- a/orangecanvas/utils/tests/test_overlay.py +++ b/orangecanvas/utils/tests/test_overlay.py @@ -3,7 +3,7 @@ import unittest.mock from AnyQt.QtCore import Qt, QEvent -from AnyQt.QtTest import QTest +from AnyQt.QtTest import QTest, QSignalSpy from AnyQt.QtWidgets import QWidget, QApplication from orangecanvas.gui.test import QAppTestCase @@ -13,6 +13,7 @@ class TestOverlay(QAppTestCase): def setUp(self) -> None: + super().setUp() self.container = QWidget() self.overlay = NotificationOverlay(self.container) self.server = NotificationServer() @@ -30,6 +31,7 @@ def tearDown(self) -> None: self.overlay = None self.notif = None self.server = None + super().tearDown() def test_notification_widget(self): stdb = NotificationWidget.Ok | NotificationWidget.Close @@ -77,8 +79,7 @@ def test_two_overlays(self): self.server.newNotification.connect(overlay2.addNotification) self.server.nextNotification.connect(overlay2.nextWidget) - mock = unittest.mock.MagicMock() - self.notif.accepted.connect(mock) + spy = QSignalSpy(self.notif.accepted) self.server.registerNotification(self.notif) @@ -94,7 +95,7 @@ def test_two_overlays(self): button = w2.button(NotificationWidget.Ok) QTest.mouseClick(button, Qt.LeftButton) - mock.assert_called_once_with() + self.assertSequenceEqual(list(spy), [[]]) self.assertFalse(w1.isVisible()) self.assertFalse(w2.isVisible())