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 repr(msgid)
    12          print repr(msgstr)
    13          print msgid.encode('utf-8')
    14          print msgstr.encode('utf-8')
    15          print corrected
    16          assert corrected == expected
    17
    18 -    def test_correct_ellipsis(self):
    19          """test that we convert single ... to three dots"""
    20          self.correct(u"String...", u"String…", u"String...")
    21
    22 -    def test_correct_spacestart_spaceend(self):
    23          """test that we can correct leading and trailing space errors"""
    24          self.correct(u"Simple string", u"Dimpled ring  ", u"Dimpled ring")
    25          self.correct(u"Simple string", u"  Dimpled ring", u"Dimpled ring")
    26          self.correct(u"  Simple string", u"Dimpled ring", u"  Dimpled ring")
    27          self.correct(u"Simple string  ", u"Dimpled ring", u"Dimpled ring  ")
    28
    29 -    def test_correct_start_capitals(self):
    30          """test that we can correct the starting capital"""
    31          self.correct(u"Simple string", u"dimpled ring", u"Dimpled ring")
    32          self.correct(u"simple string", u"Dimpled ring", u"dimpled ring")
    33
    34 -    def test_correct_end_punc(self):
    35          """test that we can correct end punctuation"""
    36          self.correct(u"Simple string:", u"Dimpled ring", u"Dimpled ring:")
    37          #self.correct(u"Simple string: ", u"Dimpled ring", u"Dimpled ring: ")
    38          self.correct(u"Simple string.", u"Dimpled ring", u"Dimpled ring.")
    39          #self.correct(u"Simple string. ", u"Dimpled ring", u"Dimpled ring. ")
    40          self.correct(u"Simple string?", u"Dimpled ring", u"Dimpled ring?")
    41