Ejemplo n.º 1
0
 def test_safelyDecodeMismatch(self):
     """
     Verify that _safelyDecode will not raise an exception when the given string
     does not match the given encoding.
     """
     self.assertEquals(u'\N{REPLACEMENT CHARACTER}',
                       mimepart._safelyDecode('\xe1', "utf8"))
Ejemplo n.º 2
0
 def test_safelyDecode(self):
     """
     Verify that _safelyDecode will properly decode a valid encoding.
     """
     self.assertEquals(
         u"\u1234", mimepart._safelyDecode(u"\u1234".encode("utf8"),
                                           "utf8"))
Ejemplo n.º 3
0
 def test_safelyDecodeMismatch(self):
     """
     Verify that _safelyDecode will not raise an exception when the given string
     does not match the given encoding.
     """
     self.assertEquals(u'\N{REPLACEMENT CHARACTER}',
                       mimepart._safelyDecode('\xe1', "utf8"))
Ejemplo n.º 4
0
 def test_safelyDecode(self):
     """
     Verify that _safelyDecode will properly decode a valid encoding.
     """
     self.assertEquals(u"\u1234",
                       mimepart._safelyDecode(u"\u1234".encode("utf8"),
                                              "utf8"))
Ejemplo n.º 5
0
 def test_safelyDecodeUnknownCodec(self):
     """
     Verify that _safelyDecode will default to ASCII decoding with replacement
     characters in the case where the provided encoding is unknown.
     """
     self.assertEquals(u'\N{REPLACEMENT CHARACTER}' * 3 + u"hello world",
                       mimepart._safelyDecode(u"\u1234hello world".encode("utf8"),
                                              "ascii"))
Ejemplo n.º 6
0
 def test_safelyDecodeUnknownCodec(self):
     """
     Verify that _safelyDecode will default to ASCII decoding with replacement
     characters in the case where the provided encoding is unknown.
     """
     self.assertEquals(
         u'\N{REPLACEMENT CHARACTER}' * 3 + u"hello world",
         mimepart._safelyDecode(u"\u1234hello world".encode("utf8"),
                                "ascii"))