diff options
author | Fred Drake <fdrake@acm.org> | 2001-05-22 15:02:19 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-05-22 15:02:19 (GMT) |
commit | cf71fefa59f50f31c2d8d49dcb75033a1651a0d7 (patch) | |
tree | 699cf869b738bb9d6d8b957b3a501b173cc23fe4 /Lib/test/test_rfc822.py | |
parent | 02959292803415fc5d66838735764aa84de8c0f8 (diff) | |
download | cpython-cf71fefa59f50f31c2d8d49dcb75033a1651a0d7.zip cpython-cf71fefa59f50f31c2d8d49dcb75033a1651a0d7.tar.gz cpython-cf71fefa59f50f31c2d8d49dcb75033a1651a0d7.tar.bz2 |
Add tests for the new .get() and .setdefault() methods of rfc822.Message
objects.
Diffstat (limited to 'Lib/test/test_rfc822.py')
-rw-r--r-- | Lib/test/test_rfc822.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index 967b91b..e59d5b3 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -1,4 +1,4 @@ -from test_support import verbose +from test_support import verbose, verify import rfc822, sys try: from cStringIO import StringIO @@ -124,3 +124,21 @@ test''', [('', 'goit@lip.com')]) test('''To: guido@[132.151.1.21] foo''', [('', 'guido@[132.151.1.21]')]) + + +msg = rfc822.Message(StringIO('''To: "last, first" <userid@foo.net> + +test +''')) +verify(msg.get("to") == '"last, first" <userid@foo.net>') +verify(msg.get("TO") == '"last, first" <userid@foo.net>') +verify(msg.get("No-Such-Header") is None) +verify(msg.get("No-Such-Header", "No-Such-Value") == "No-Such-Value") + +verify(not msg.has_key("New-Header")) +verify(msg.setdefault("New-Header", "New-Value") == "New-Value") +verify(msg.setdefault("New-Header", "Different-Value") == "New-Value") +verify(msg["new-header"] == "New-Value") + +verify(msg.setdefault("Another-Header") == "") +verify(msg["another-header"] == "") |