mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Add tests for the new .get() and .setdefault() methods of rfc822.Message
objects.
This commit is contained in:
parent
0295929280
commit
cf71fefa59
1 changed files with 19 additions and 1 deletions
|
@ -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"] == "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue