summaryrefslogtreecommitdiffstats
path: root/Lib/email/test
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2002-09-06 03:39:59 (GMT)
committerBarry Warsaw <barry@python.org>2002-09-06 03:39:59 (GMT)
commit58fb61cce5f989ea4b3cc48ce104235b8eb5965d (patch)
tree336a64c6a79534d1f4109c281314d8e27d048cb3 /Lib/email/test
parent229727fa0738562c22b7bdc672a8762886020eac (diff)
downloadcpython-58fb61cce5f989ea4b3cc48ce104235b8eb5965d.zip
cpython-58fb61cce5f989ea4b3cc48ce104235b8eb5965d.tar.gz
cpython-58fb61cce5f989ea4b3cc48ce104235b8eb5965d.tar.bz2
test_replace_header(): New test for Message.replace_header().
Diffstat (limited to 'Lib/email/test')
-rw-r--r--Lib/email/test/test_email.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 5012d43..bd075ce 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -435,6 +435,23 @@ class TestMessageAPI(TestEmailBase):
msg['Content-Type'] = 'no-slash-in-this-string'
self.assertEqual(msg.get_content_subtype(), 'plain')
+ def test_replace_header(self):
+ eq = self.assertEqual
+ msg = Message()
+ msg.add_header('First', 'One')
+ msg.add_header('Second', 'Two')
+ msg.add_header('Third', 'Three')
+ eq(msg.keys(), ['First', 'Second', 'Third'])
+ eq(msg.values(), ['One', 'Two', 'Three'])
+ msg.replace_header('Second', 'Twenty')
+ eq(msg.keys(), ['First', 'Second', 'Third'])
+ eq(msg.values(), ['One', 'Twenty', 'Three'])
+ msg.add_header('First', 'Eleven')
+ msg.replace_header('First', 'One Hundred')
+ eq(msg.keys(), ['First', 'Second', 'Third', 'First'])
+ eq(msg.values(), ['One Hundred', 'Twenty', 'Three', 'Eleven'])
+ self.assertRaises(KeyError, msg.replace_header, 'Fourth', 'Missing')
+
# Test the email.Encoders module