Skip to content

Commit 5b47f94

Browse files
committed
Fix silliness in test
1 parent 063b169 commit 5b47f94

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/src/python/test_qgsmessagelog.py

+9-19
Original file line numberDiff line numberDiff line change
@@ -31,71 +31,61 @@
3131
class TestQgsMessageLog(unittest.TestCase):
3232

3333
def testSignals(self):
34-
local_log = QgsMessageLog()
3534
app_log = QgsApplication.messageLog()
3635

37-
# signals should only be emitted by application log, not local log
38-
local_spy = QSignalSpy(local_log.messageReceived)
39-
local_spy_received = QSignalSpy(local_log.messageReceived[bool])
36+
# signals should be emitted by application log
4037
app_spy = QSignalSpy(app_log.messageReceived)
4138
app_spy_received = QSignalSpy(app_log.messageReceived[bool])
4239

43-
local_log.logMessage('test', 'tag', Qgis.Info, notifyUser=True)
44-
self.assertEqual(len(local_spy), 0)
45-
self.assertEqual(len(local_spy_received), 0)
40+
QgsMessageLog.logMessage('test', 'tag', Qgis.Info, notifyUser=True)
4641
self.assertEqual(len(app_spy), 1)
4742
self.assertEqual(app_spy[-1], ['test', 'tag', Qgis.Info])
4843
# info message, so messageReceived(bool) should not be emitted
4944
self.assertEqual(len(app_spy_received), 0)
5045

51-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
52-
self.assertEqual(len(local_spy), 0)
53-
self.assertEqual(len(local_spy_received), 0)
46+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
5447
self.assertEqual(len(app_spy), 2)
5548
self.assertEqual(app_spy[-1], ['test', 'tag', Qgis.Warning])
5649
# warning message, so messageReceived(bool) should be emitted
5750
self.assertEqual(len(app_spy_received), 1)
5851

59-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=False)
60-
self.assertEqual(len(local_spy), 0)
61-
self.assertEqual(len(local_spy_received), 0)
52+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=False)
6253
self.assertEqual(len(app_spy), 3)
6354
# notifyUser was False
6455
self.assertEqual(len(app_spy_received), 1)
6556

6657
def testBlocker(self):
67-
local_log = QgsMessageLog()
6858
app_log = QgsApplication.messageLog()
6959

7060
spy = QSignalSpy(app_log.messageReceived)
7161
spy_received = QSignalSpy(app_log.messageReceived[bool])
7262

73-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
63+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
7464
self.assertEqual(len(spy), 1)
7565
self.assertEqual(spy[-1], ['test', 'tag', Qgis.Warning])
7666
self.assertEqual(len(spy_received), 1)
7767

7868
# block notifications
7969
b = QgsMessageLogNotifyBlocker()
80-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
70+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
8171
self.assertEqual(len(spy), 2) # should not be blocked
8272
self.assertEqual(len(spy_received), 1) # should be blocked
8373

8474
# another blocker
8575
b2 = QgsMessageLogNotifyBlocker()
86-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
76+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
8777
self.assertEqual(len(spy), 3) # should not be blocked
8878
self.assertEqual(len(spy_received), 1) # should be blocked
8979

9080
del b
9181
# still blocked because of b2
92-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
82+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
9383
self.assertEqual(len(spy), 4) # should not be blocked
9484
self.assertEqual(len(spy_received), 1) # should be blocked
9585

9686
del b2
9787
# not blocked
98-
local_log.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
88+
QgsMessageLog.logMessage('test', 'tag', Qgis.Warning, notifyUser=True)
9989
self.assertEqual(len(spy), 5) # should not be blocked
10090
self.assertEqual(len(spy_received), 2) # should not be blocked
10191

0 commit comments

Comments
 (0)