]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
test_body_encoding(): a new test for Charset.body_encode(), especially
authorBarry Warsaw <barry@python.org>
Mon, 21 Oct 2002 05:43:58 +0000 (05:43 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 21 Oct 2002 05:43:58 +0000 (05:43 +0000)
one that tests the obscure bug reported in SF # 625509.

Lib/email/test/test_email.py

index 5b93d8b86e2a52a93a6dddd87d6978c4ffd9b09a..6a365815548f3fa5a5fa3de14a37496fa2e53fbe 100644 (file)
@@ -2080,6 +2080,13 @@ two line""")
 \f
 # Test the Charset class
 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):
         eq = self.assertEqual
         # Make sure us-ascii = no Unicode conversion
@@ -2114,6 +2121,13 @@ class TestCharset(unittest.TestCase):
         except LookupError:
             # We probably don't have the Japanese codecs installed
             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'))
 
 
 \f