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))
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))
def test_sanitizer_None(self): # None is returned as None. sanitizer = Sanitizer(u"Text without whitespace.") self.assertIs(sanitizer.sanitize(None), None)
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)
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)