MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_body_encode

Method test_body_encode

Lib/test/test_email/test_email.py:5045–5074  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5043 eq(c.header_encode(s), '=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=')
5044
5045 def test_body_encode(self):
5046 eq = self.assertEqual
5047 # Try a charset with QP body encoding
5048 c = Charset('iso-8859-1')
5049 eq('hello w=F6rld', c.body_encode('hello w\xf6rld'))
5050 # Try a charset with Base64 body encoding
5051 c = Charset('utf-8')
5052 eq('aGVsbG8gd29ybGQ=\n', c.body_encode(b'hello world'))
5053 # Try a charset with None body encoding
5054 c = Charset('us-ascii')
5055 eq('hello world', c.body_encode('hello world'))
5056 # Try the convert argument, where input codec != output codec
5057 c = Charset('euc-jp')
5058 # With apologies to Tokio Kikuchi ;)
5059 # XXX FIXME
5060## try:
5061## eq('\x1b$B5FCO;~IW\x1b(B',
5062## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
5063## eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7',
5064## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
5065## except LookupError:
5066## # We probably don't have the Japanese codecs installed
5067## pass
5068 # Testing SF bug #625509, which we have to fake, since there are no
5069 # built-in encodings where the header encoding is QP but the body
5070 # encoding is not.
5071 from email import charset as CharsetModule
5072 CharsetModule.add_charset('fake', CharsetModule.QP, None, 'utf-8')
5073 c = Charset('fake')
5074 eq('hello world', c.body_encode('hello world'))
5075
5076 def test_unicode_charset_name(self):
5077 charset = Charset('us-ascii')

Callers

nothing calls this directly

Calls 3

body_encodeMethod · 0.95
CharsetClass · 0.90
eqFunction · 0.50

Tested by

no test coverage detected