Ejemplo n.º 1
0
 def test_to_unicode_decodes_to_unicode(self):
     # Byte strings are decoded as ASCII by _to_unicode(), replacing
     # all non-ASCII characters with U+FFFD REPLACEMENT CHARACTERs.
     byte_string = b"This string will be converted. \xe5\xb2\x81\xe5."
     expected_unicode_string = (
         "This string will be converted. \ufffd\ufffd\ufffd\ufffd.")
     converted_string = ExternalProcessError._to_unicode(byte_string)
     self.assertIsInstance(converted_string, str)
     self.assertEqual(expected_unicode_string, converted_string)
Ejemplo n.º 2
0
 def test_to_unicode_defers_to_unicode_constructor(self):
     # Unicode strings and non-byte strings are handed to unicode()
     # to undergo Python's normal coercion strategy. (For unicode
     # strings this is actually a no-op, but it's cheaper to do this
     # than special-case unicode strings.)
     self.assertEqual(str(self), ExternalProcessError._to_unicode(self))