def get_mode(editor): try: mode = editor.modes.get(modes.CheckerMode) except KeyError: mode = modes.CheckerMode(check) editor.modes.append(mode) return mode
def __init__(self, parent=None, server_script=None, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt', reuse_backend=True): super(RstCodeEdit, self).__init__(parent, create_default_actions) if server_script is None: server_script = self.DEFAULT_SERVER print 'is freezed?', hasattr(sys, 'frozen') print self.DEFAULT_SERVER print sys.executable print os.getcwd() sys.frozen = True self.backend.start(server_script, interpreter, args, reuse=reuse_backend) # append panels self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.TOP) # append modes self.modes.append(modes.CursorHistoryMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) # self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(rstmodes.RstSH(self.document(), color_scheme=api.ColorScheme(color_scheme))) self.modes.append(modes.ZoomMode()) cc = modes.CodeCompletionMode() cc.trigger_symbols[:] = [] self.modes.append(cc) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(modes.CheckerMode(workers.linter)) self.panels.append(panels.EncodingPanel(), api.Panel.Position.TOP) self.panels.append(panels.ReadOnlyPanel(), api.Panel.Position.TOP) self.panels.append(panels.CheckerPanel())
def test_request_analysis(editor): try: mode = get_mode(editor) except KeyError: mode = modes.CheckerMode(check) editor.modes.append(mode) editor.backend.stop() mode.clear_messages() if editor.backend.running: editor.backend.stop() # 1st analysis will be retried while server is # not connected mode.request_analysis() QTest.qWait(500) editor.backend.start(server_path()) wait_for_connected(editor) # ok now it should complete in a few milliseconds QTest.qWait(500) assert len(mode._messages) == 0 editor.panels.append(panels.MarkerPanel()) # 2nd analysis should return 1 msg mode.request_analysis() QTest.qWait(3000) assert len(mode._messages) == 1 mode.clear_messages() # 3rd analtsus should return 40 msgs mode.request_analysis() QTest.qWait(3000) assert len(mode._messages) == 150 mode.request_analysis() QTest.qWait(600) mode.request_analysis() QTest.qWait(3000) mode.request_analysis() QTest.qWait(3000) assert len(mode._messages) == 20 editor.panels.remove(panels.MarkerPanel) mode.clear_messages()