Beispiel #1
0
    def test_normalizeWhitespace_only_whitespace(self):
        # If a translation is only whitespace, it will be turned into the
        # empty string.
        sanitizer = Sanitizer(u"English")
        only_whitespace = u"    "

        self.assertEqual(u'', sanitizer.normalizeWhitespace(only_whitespace))
    def test_normalizeWhitespace_only_whitespace(self):
        # If a translation is only whitespace, it will be turned into the
        # empty string.
        sanitizer = Sanitizer(u"English")
        only_whitespace = u"    "

        self.assertEqual(u'', sanitizer.normalizeWhitespace(only_whitespace))
Beispiel #3
0
    def test_normalizeWhitespace_only_whitespace_everywhere(self):
        # Corner case: only whitespace in English and translation will
        # normalize to the English string.
        english_whitespace = u"  "
        sanitizer = Sanitizer(english_whitespace)
        only_whitespace = u"    "

        self.assertEqual(english_whitespace,
                         sanitizer.normalizeWhitespace(only_whitespace))
Beispiel #4
0
    def test_normalizeWhitespace_add_and_remove(self):
        # Leading and trailing white space in the translation are synced to
        # what the English text has.
        sanitizer = Sanitizer(u"  English with leading white space.")
        translation = u"Text with trailing white space.  "
        expected_sanitized = u"  Text with trailing white space."

        self.assertEqual(expected_sanitized,
                         sanitizer.normalizeWhitespace(translation))
    def test_normalizeWhitespace_only_whitespace_everywhere(self):
        # Corner case: only whitespace in English and translation will
        # normalize to the English string.
        english_whitespace = u"  "
        sanitizer = Sanitizer(english_whitespace)
        only_whitespace = u"    "

        self.assertEqual(
            english_whitespace,
            sanitizer.normalizeWhitespace(only_whitespace))
    def test_normalizeWhitespace_add_and_remove(self):
        # Leading and trailing white space in the translation are synced to
        # what the English text has.
        sanitizer = Sanitizer(u"  English with leading white space.")
        translation = u"Text with trailing white space.  "
        expected_sanitized = u"  Text with trailing white space."

        self.assertEqual(
            expected_sanitized,
            sanitizer.normalizeWhitespace(translation))