def test_add_messages(editor): mode = get_mode(editor) mode.clear_messages() status = [modes.CheckerMessages.ERROR, modes.CheckerMessages.WARNING, modes.CheckerMessages.INFO] mode.add_messages([modes.CheckerMessage('desc', random.choice(status), 10 + i) for i in range(500)]) assert len(mode._messages) < 500 QTest.qWait(500)
def test_checker_message(): assert modes.CheckerMessage.status_to_string( modes.CheckerMessages.INFO) == 'Info' assert modes.CheckerMessage.status_to_string( modes.CheckerMessages.WARNING) == 'Warning' assert modes.CheckerMessage.status_to_string( modes.CheckerMessages.ERROR) == 'Error' msg = modes.CheckerMessage('desc', modes.CheckerMessages.ERROR, 10, col=15, path=__file__) assert msg.status_string == 'Error'
def test_remove_message(editor): mode = get_mode(editor) QTest.qWait(5000) mode.clear_messages() status = [modes.CheckerMessages.ERROR, modes.CheckerMessages.WARNING, modes.CheckerMessages.INFO] mode.add_messages([modes.CheckerMessage('desc', modes.CheckerMessages.ERROR, 10 + i) for i in range(mode.limit * 2)]) while not mode._finished: QTest.qWait(5000) assert len(mode._messages) == mode.limit QTest.qWait(5000) mode.remove_message(mode._messages[10]) QTest.qWait(5000) assert len(mode._messages) == mode.limit - 1 mode.clear_messages()
def _on_work_finished(self, results): """ Display results. :param status: Response status :param results: Response data, messages. """ messages = [] for msg in results: msg = modes.CheckerMessage(*msg) msg.line -= server._header_num_lines if msg.line < 0: continue block = self.editor.document().findBlockByNumber(msg.line) msg.block = block messages.append(msg) self.add_messages(messages)