def test_save(self): name = 'TEST save highlighter' foreground = 'white' background = 'blue' terms = ['a','b', 'c'] h = Highlighter(TEST_SAVE_HIGHLIGHTER, name, foreground, background) h.terms = terms h.save() try: with open(TEST_SAVE_HIGHLIGHTER, 'r') as f: lines = f.readlines() self.assertEqual(lines[0].strip(), name) self.assertEqual(lines[1].strip(), foreground) self.assertEqual(lines[2].strip(), background) self.assertEqual(lines[3].strip(), terms[0]) self.assertEqual(lines[4].strip(), terms[1]) self.assertEqual(lines[5].strip(), terms[2]) except Exception as e: self.fail()
def __init__(self, parent=None): super(Editor, self).__init__(parent) self.model = Model.Model() self.configs = self.model.read_config('config.ini') self.set_ui() Highlighter.MarkdownHighlighter(self) self.connect(self,SIGNAL("editor_test"),self.editor_test)
def test_addTerm(self): h = Highlighter(TEST_LOAD_HIGHLIGHTER) h.addTerm(TERM_B) h.addTerm(TERM_C) h.addTerm(TERM_A) # Terms are added in alphabetical order self.assertEqual(h.terms, [TERM_A, TERM_B, TERM_C])
def __init__(self, name, text, parent=None): super(ActivityTab, self).__init__(parent) self.name = name self.text = text self.mainLayout = QtGui.QVBoxLayout() self.editor = Editor.Editor() self.mainLayout.addWidget(self.editor) self.highlight = Highlighter.Highlighter(self.editor.document()) self.editor.setPlainText(self.text[0]) #self.setFixedSize(500,500) self.setLayout(self.mainLayout) self.editor.textCursor().setPosition(0, QtGui.QTextCursor.MoveAnchor)
def setupUi(self): """Initializes the UI componenets for the main window""" # Actions self.action_manager = ActionManager(self) # Menu bar and status bar self.setMenuBar(QMenuBar(self)) self.setStatusBar(QStatusBar(self)) self.create_menus() self.create_toolbars() # Set central widget to textedit with highlighter self.text_edit = CodeEdit() self.text_edit.set_text_changed_handler(self.document_changed_handler) self.highlighter = Highlighter(self.text_edit.document()) self.setCentralWidget(self.text_edit) # Create docked widgets self.create_docked_widgets() # Show window self.setWindowTitle('Automark ' + VERSION_NO) self.resize(1440, 800) self.show()
def test_load(self): h = Highlighter(TEST_LOAD_HIGHLIGHTER) self.assertEqual(h.name, 'TEST Highlighter') self.assertEqual(h.foreground, 'blue') self.assertEqual(h.background, 'yellow')
def test_removeTerm(self): h = Highlighter(TEST_LOAD_HIGHLIGHTER) h.terms = ['a', 'b', 'c'] self.assertTrue(h.containsTerm('b'))
def test_removeTerm(self): h = Highlighter(TEST_LOAD_HIGHLIGHTER) h.terms = [TERM_A, TERM_B, TERM_C] h.removeTerm(TERM_B) self.assertEqual(h.terms, [TERM_A, TERM_C])