Exemplo n.º 1
0
 def test_sanitize(self):
     # Calling the Sanitizer object will apply all sanitization procedures.
     sanitizer = Sanitizer(u"Text with\nnewline.")
     translation_text = (
         u"Translation with\r\nnewline dots\u2022and whitespace.  ")
     expected_sanitized = (
         u"Translation with\nnewline dots and whitespace.")
     self.assertEqual(expected_sanitized,
                      sanitizer.sanitize(translation_text))
Exemplo n.º 2
0
 def test_sanitize(self):
     # Calling the Sanitizer object will apply all sanitization procedures.
     sanitizer = Sanitizer(u"Text with\nnewline.")
     translation_text = (
             u"Translation with\r\nnewline dots\u2022and whitespace.  ")
     expected_sanitized = (
             u"Translation with\nnewline dots and whitespace.")
     self.assertEqual(
         expected_sanitized, sanitizer.sanitize(translation_text))
Exemplo n.º 3
0
 def test_sanitizer_None(self):
     # None is returned as None.
     sanitizer = Sanitizer(u"Text without whitespace.")
     self.assertIs(sanitizer.sanitize(None), None)
Exemplo n.º 4
0
 def test_sanitize_whitespace_string(self):
     # A whitespace only string will be normalized to None.
     sanitizer = Sanitizer(u"Text without whitespace.")
     empty_translation_text = (u"  ")
     self.assertTrue(sanitizer.sanitize(empty_translation_text) is None)
Exemplo n.º 5
0
 def test_sanitizer_None(self):
     # None is returned as None.
     sanitizer = Sanitizer(u"Text without whitespace.")
     self.assertIs(sanitizer.sanitize(None), None)
Exemplo n.º 6
0
 def test_sanitize_whitespace_string(self):
     # A whitespace only string will be normalized to None.
     sanitizer = Sanitizer(u"Text without whitespace.")
     empty_translation_text = (u"  ")
     self.assertTrue(
         sanitizer.sanitize(empty_translation_text) is None)