diff options
author | Barry Warsaw <barry@python.org> | 2007-08-31 03:26:19 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2007-08-31 03:26:19 (GMT) |
commit | 7aa02e6590e2155e8f72bb4491c96db40a50cac3 (patch) | |
tree | 8ada82dce8e2095d168bcac349b787fb7475c03b /Lib/email | |
parent | 0616b792ba4115fe3bb79c446c2c6383db434490 (diff) | |
download | cpython-7aa02e6590e2155e8f72bb4491c96db40a50cac3.zip cpython-7aa02e6590e2155e8f72bb4491c96db40a50cac3.tar.gz cpython-7aa02e6590e2155e8f72bb4491c96db40a50cac3.tar.bz2 |
More email package fixes.
Fix a couple of tests since .body_encode()'s arguments have changed. Also, I
think body_encode() should take a string not a byte array for consistency with
the rest of the api (but I'm not positive about this). In
quoprimime.body_encode(), body_check() must be passed an int.
Current status: 7F (no errors!)
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/quoprimime.py | 2 | ||||
-rw-r--r-- | Lib/email/test/test_email.py | 17 |
2 files changed, 9 insertions, 10 deletions
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py index e59479c..68dc11c 100644 --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -189,7 +189,7 @@ def body_encode(body, maxlinelen=76, eol=NL): for j in range(linelen): c = line[j] prev = c - if body_check(c): + if body_check(ord(c)): c = quote(c) elif j+1 == linelen: # Check for whitespace at end of line; special case diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 15c8325..104840a 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2555,7 +2555,6 @@ class TestBase64(unittest.TestCase): eq(base64mime.body_encode('hello'), 'aGVsbG8=\n') # Test the binary flag eq(base64mime.body_encode('hello\n'), 'aGVsbG8K\n') - eq(base64mime.body_encode('hello\n', 0), 'aGVsbG8NCg==\n') # Test the maxlinelen arg eq(base64mime.body_encode('xxxx ' * 20, maxlinelen=40), """\ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg @@ -2564,7 +2563,8 @@ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IA== """) # Test the eol argument - eq(base64mime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\ + eq(base64mime.body_encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), + """\ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r @@ -2681,7 +2681,6 @@ class TestQuopri(unittest.TestCase): eq(quoprimime.body_encode('hello'), 'hello') # Test the binary flag eq(quoprimime.body_encode('hello\r\nworld'), 'hello\nworld') - eq(quoprimime.body_encode('hello\r\nworld', 0), 'hello\nworld') # Test the maxlinelen arg eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40), """\ xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx= @@ -2727,21 +2726,21 @@ class TestCharset(unittest.TestCase): eq = self.assertEqual # Try a charset with QP body encoding c = Charset('iso-8859-1') - eq('hello w=F6rld', c.body_encode(b'hello w\xf6rld')) + 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(b'hello world')) + 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(b'hello world')) + 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(b'\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7')) + c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7')) eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', - c.body_encode(b'\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False)) + c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False)) except LookupError: # We probably don't have the Japanese codecs installed pass @@ -2751,7 +2750,7 @@ class TestCharset(unittest.TestCase): from email import charset as CharsetModule CharsetModule.add_charset('fake', CharsetModule.QP, None) c = Charset('fake') - eq('hello w\xf6rld', c.body_encode(b'hello w\xf6rld')) + eq('hello w\xf6rld', c.body_encode('hello w\xf6rld')) def test_unicode_charset_name(self): charset = Charset('us-ascii') |