test_body_encoding(): a new test for Charset.body_encode(), especially

one that tests the obscure bug reported in SF # 625509.
This commit is contained in:
Barry Warsaw 2002-10-21 05:43:58 +00:00
parent 34aa44538d
commit 4111804548
1 changed files with 14 additions and 0 deletions

View File

@ -2080,6 +2080,13 @@ two line""")
# Test the Charset class # Test the Charset class
class TestCharset(unittest.TestCase): class TestCharset(unittest.TestCase):
def tearDown(self):
from email import Charset as CharsetModule
try:
del CharsetModule.CHARSETS['fake']
except KeyError:
pass
def test_idempotent(self): def test_idempotent(self):
eq = self.assertEqual eq = self.assertEqual
# Make sure us-ascii = no Unicode conversion # Make sure us-ascii = no Unicode conversion
@ -2114,6 +2121,13 @@ class TestCharset(unittest.TestCase):
except LookupError: except LookupError:
# We probably don't have the Japanese codecs installed # We probably don't have the Japanese codecs installed
pass pass
# Testing SF bug #625509, which we have to fake, since there are no
# built-in encodings where the header encoding is QP but the body
# encoding is not.
from email import Charset as CharsetModule
CharsetModule.add_charset('fake', CharsetModule.QP, None)
c = Charset('fake')
eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))