def test_inserting_dictionary(self): text = 'hellp\nhellp\n' checker = SpellChecker(text, aspell=self.aspell, save_dict=False) result = checker.check() typo = result.next() checker.insert_dictionary('hellp') self._assert_ended(result)
def test_accepting_words_on_the_same_line(self): text = 'hellp hellp\n' checker = SpellChecker(text, aspell=self.aspell) result = checker.check() typo = result.next() checker.accept_word('hellp') self._assert_ended(result)
def test_lines_starting_with_aspell_signs(self): checker = SpellChecker('* hellp', aspell=self.aspell) result = checker.check() typo = result.next() self.assertEquals('hellp', typo.original) self.assertEquals(2, typo.offset) self._assert_ended(result)
def test_multi_lines(self): text = 'correct\n hellp\n' checker = SpellChecker(text, aspell=self.aspell) result = checker.check() typo = result.next() self.assertEquals('hellp', typo.original) self.assertEquals(text.index('hellp'), typo.offset) self._assert_ended(result)
def test_offset_and_suggestions(self): checker = SpellChecker('hellp', aspell=self.aspell) result = checker.check() typo = result.next() self.assertEquals('hellp', typo.original) self.assertEquals(0, typo.offset) self.assertTrue(len(typo.suggestions) > 0) self._assert_ended(result)
def test_more_than_one_error(self): text = 'hellp\n hellp\n' checker = SpellChecker(text, aspell=self.aspell) result = checker.check() typo = result.next() self.assertEquals('hellp', typo.original) self.assertEquals(text.index('hellp'), typo.offset) typo = result.next() self.assertEquals('hellp', typo.original) self.assertEquals(text.rindex('hellp'), typo.offset) self._assert_ended(result)
def __init__(self, context, start, end): self.editor = context.editor self.offset = start self.text = self.editor.get_text()[start:end] self.checker = SpellChecker(self.text) self.typos = self.checker.check() self.changed_offset = start self.semaphore = threading.Semaphore(0)
class _SpellCheckingDialog(object): def __init__(self, context, start, end): self.editor = context.editor self.offset = start self.text = self.editor.get_text()[start:end] self.checker = SpellChecker(self.text) self.typos = self.checker.check() self.changed_offset = start self.semaphore = threading.Semaphore(0) def do(self): try: while True: typo = self.typos.next() typo_dialog = _TypoDialog(typo, self) typo_dialog() except StopIteration: pass def quit(self): self.checker.quit()
def test_simple_error(self): checker = SpellChecker('hellp', aspell=self.aspell) result = checker.check() self.assertEquals('hellp', result.next().original) self._assert_ended(result)
def test_no_errors(self): checker = SpellChecker('hello', aspell=self.aspell) self.assertEquals([], list(checker.check()))
def test_trivial_case(self): checker = SpellChecker('', aspell=self.aspell) self.assertEquals([], list(checker.check()))