(self)
| 4973 | eq(c.header_encode(s), '=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=') |
| 4974 | |
| 4975 | def test_body_encode(self): |
| 4976 | eq = self.assertEqual |
| 4977 | # Try a charset with QP body encoding |
| 4978 | c = Charset('iso-8859-1') |
| 4979 | eq('hello w=F6rld', c.body_encode('hello w\xf6rld')) |
| 4980 | # Try a charset with Base64 body encoding |
| 4981 | c = Charset('utf-8') |
| 4982 | eq('aGVsbG8gd29ybGQ=\n', c.body_encode(b'hello world')) |
| 4983 | # Try a charset with None body encoding |
| 4984 | c = Charset('us-ascii') |
| 4985 | eq('hello world', c.body_encode('hello world')) |
| 4986 | # Try the convert argument, where input codec != output codec |
| 4987 | c = Charset('euc-jp') |
| 4988 | # With apologies to Tokio Kikuchi ;) |
| 4989 | # XXX FIXME |
| 4990 | ## try: |
| 4991 | ## eq('\x1b$B5FCO;~IW\x1b(B', |
| 4992 | ## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7')) |
| 4993 | ## eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', |
| 4994 | ## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False)) |
| 4995 | ## except LookupError: |
| 4996 | ## # We probably don't have the Japanese codecs installed |
| 4997 | ## pass |
| 4998 | # Testing SF bug #625509, which we have to fake, since there are no |
| 4999 | # built-in encodings where the header encoding is QP but the body |
| 5000 | # encoding is not. |
| 5001 | from email import charset as CharsetModule |
| 5002 | CharsetModule.add_charset('fake', CharsetModule.QP, None, 'utf-8') |
| 5003 | c = Charset('fake') |
| 5004 | eq('hello world', c.body_encode('hello world')) |
| 5005 | |
| 5006 | def test_unicode_charset_name(self): |
| 5007 | charset = Charset('us-ascii') |
nothing calls this directly
no test coverage detected