Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4111804

Browse files
committed
test_body_encoding(): a new test for Charset.body_encode(), especially
one that tests the obscure bug reported in SF # 625509.
1 parent 34aa445 commit 4111804

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/email/test/test_email.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,13 @@ def test_encode(self):
20802080

20812081
# Test the Charset class
20822082
class TestCharset(unittest.TestCase):
2083+
def tearDown(self):
2084+
from email import Charset as CharsetModule
2085+
try:
2086+
del CharsetModule.CHARSETS['fake']
2087+
except KeyError:
2088+
pass
2089+
20832090
def test_idempotent(self):
20842091
eq = self.assertEqual
20852092
# Make sure us-ascii = no Unicode conversion
@@ -2114,6 +2121,13 @@ def test_body_encode(self):
21142121
except LookupError:
21152122
# We probably don't have the Japanese codecs installed
21162123
pass
2124+
# Testing SF bug #625509, which we have to fake, since there are no
2125+
# built-in encodings where the header encoding is QP but the body
2126+
# encoding is not.
2127+
from email import Charset as CharsetModule
2128+
CharsetModule.add_charset('fake', CharsetModule.QP, None)
2129+
c = Charset('fake')
2130+
eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))
21172131

21182132

21192133

0 commit comments

Comments
 (0)