Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
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()
Exemplo n.º 9
0
 def test_simple_error(self):
     checker = SpellChecker('hellp', aspell=self.aspell)
     result = checker.check()
     self.assertEquals('hellp', result.next().original)
     self._assert_ended(result)
Exemplo n.º 10
0
 def test_no_errors(self):
     checker = SpellChecker('hello', aspell=self.aspell)
     self.assertEquals([], list(checker.check()))
Exemplo n.º 11
0
 def test_trivial_case(self):
     checker = SpellChecker('', aspell=self.aspell)
     self.assertEquals([], list(checker.check()))