diff options
author | Barry Warsaw <barry@python.org> | 2002-10-21 05:31:08 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-10-21 05:31:08 (GMT) |
commit | 34aa44538d894e1b3bc1bf12a42f60c0fd74ccde (patch) | |
tree | c6f490c93adf9f3aba50ef67feccc4d35e463200 /Lib/email/test/test_email.py | |
parent | 3d57589f0fe4e682df2961294b5cf23571cab70f (diff) | |
download | cpython-34aa44538d894e1b3bc1bf12a42f60c0fd74ccde.zip cpython-34aa44538d894e1b3bc1bf12a42f60c0fd74ccde.tar.gz cpython-34aa44538d894e1b3bc1bf12a42f60c0fd74ccde.tar.bz2 |
test_body_encoding(): a new test
Diffstat (limited to 'Lib/email/test/test_email.py')
-rw-r--r-- | Lib/email/test/test_email.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 176e774..5b93d8b 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2092,6 +2092,29 @@ class TestCharset(unittest.TestCase): sp = c.to_splittable(s) eq(s, c.from_splittable(sp)) + def test_body_encode(self): + eq = self.assertEqual + # Try a charset with QP body encoding + c = Charset('iso-8859-1') + eq('hello w=F6rld', c.body_encode('hello w\xf6rld')) + # Try a charset with Base64 body encoding + c = Charset('utf-8') + eq('aGVsbG8gd29ybGQ=\n', c.body_encode('hello world')) + # Try a charset with None body encoding + c = Charset('us-ascii') + eq('hello world', c.body_encode('hello world')) + # Try the convert argument, where input codec <> output codec + c = Charset('euc-jp') + # With apologies to Tokio Kikuchi ;) + try: + eq('\x1b$B5FCO;~IW\x1b(B', + c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7')) + eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', + c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False)) + except LookupError: + # We probably don't have the Japanese codecs installed + pass + # Test multilingual MIME headers. |