From: Barry Warsaw Date: Mon, 16 Aug 2004 15:31:43 +0000 (+0000) Subject: Test cases and fixes for bugs described in patch #873418: email/Message.py: X-Git-Tag: v2.3.5c1~132 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8dcec1381eef7420b0f83395c323eceec8fea19d;p=thirdparty%2FPython%2Fcpython.git Test cases and fixes for bugs described in patch #873418: email/Message.py: del_param fails when specifying a header. I'll port this to Python 2.4 shortly. --- diff --git a/Lib/email/Message.py b/Lib/email/Message.py index 9f826d81613a..aefa37f14f09 100644 --- a/Lib/email/Message.py +++ b/Lib/email/Message.py @@ -672,7 +672,7 @@ class Message: if not self.has_key(header): return new_ctype = '' - for p, v in self.get_params(header, unquote=requote): + for p, v in self.get_params(header=header, unquote=requote): if p.lower() <> param.lower(): if not new_ctype: new_ctype = _formatparam(p, v, requote) @@ -708,7 +708,7 @@ class Message: if not self.has_key(header): self[header] = type return - params = self.get_params(header, unquote=requote) + params = self.get_params(header=header, unquote=requote) del self[header] self[header] = type # Skip the first param; it's the old type. diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index dd2249fde7b6..8204f463c89a 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -361,6 +361,12 @@ class TestMessageAPI(TestEmailBase): ('boundary', 'D1690A7AC1.996856090/mail.example.com'), ('report-type', old_val)]) + def test_del_param_on_other_header(self): + msg = Message() + msg.add_header('Content-Disposition', 'attachment', filename='bud.gif') + msg.del_param('filename', 'content-disposition') + self.assertEqual(msg['content-disposition'], 'attachment') + def test_set_type(self): eq = self.assertEqual msg = Message() @@ -372,6 +378,12 @@ class TestMessageAPI(TestEmailBase): msg.set_type('text/html') eq(msg['content-type'], 'text/html; charset="us-ascii"') + def test_set_type_on_other_header(self): + msg = Message() + msg['X-Content-Type'] = 'text/plain' + msg.set_type('application/octet-stream', 'X-Content-Type') + self.assertEqual(msg['x-content-type'], 'application/octet-stream') + def test_get_content_type_missing(self): msg = Message() self.assertEqual(msg.get_content_type(), 'text/plain')