Package translate :: Package filters :: Module test_autocorrect
[hide private]
[frames] | no frames]

Source Code for Module translate.filters.test_autocorrect

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  from translate.filters import autocorrect 
 5   
6 -class TestAutocorrect:
7
8 - def correct(self, msgid, msgstr, expected):
9 """helper to run correct function from autocorrect module""" 10 corrected = autocorrect.correct(msgid, msgstr) 11 print msgid 12 print msgstr 13 print corrected 14 assert corrected == expected
15
16 - def test_correct_ellipsis(self):
17 """test that we convert single ... to three dots""" 18 self.correct("String...", "String…", "String...")
19
21 """test that we can correct leading and trailing space errors""" 22 self.correct("Simple string", "Dimpled ring ", "Dimpled ring") 23 self.correct("Simple string", " Dimpled ring", "Dimpled ring") 24 self.correct(" Simple string", "Dimpled ring", " Dimpled ring") 25 self.correct("Simple string ", "Dimpled ring", "Dimpled ring ")
26
28 """test that we can correct the starting capital""" 29 self.correct("Simple string", "dimpled ring", "Dimpled ring") 30 self.correct("simple string", "Dimpled ring", "dimpled ring")
31
32 - def test_correct_end_punc(self):
33 """test that we can correct end punctuation""" 34 self.correct("Simple string:", "Dimpled ring", "Dimpled ring:") 35 #self.correct("Simple string: ", "Dimpled ring", "Dimpled ring: ") 36 self.correct("Simple string.", "Dimpled ring", "Dimpled ring.") 37 #self.correct("Simple string. ", "Dimpled ring", "Dimpled ring. ") 38 self.correct("Simple string?", "Dimpled ring", "Dimpled ring?")
39