8000 #gh-75705: Set unixfrom envelope in mailbox._mboxMMDF by matthieucan · Pull Request #107117 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

#gh-75705: Set unixfrom envelope in mailbox._mboxMMDF #107117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests for get_unixfrom().
  • Loading branch information
serhiy-storchaka committed Feb 1, 2024
commit 0982e7ad7fdceef75ace17956251662c4eecec1c
10 changes: 9 additions & 1 deletion Lib/test/test_mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,18 +1669,23 @@ def test_initialize_with_unixfrom(self):
msg = mailbox.Message(_sample_message)
msg.set_unixfrom('From foo@bar blah')
msg = mailbox.mboxMessage(msg)
self.assertEqual(msg.get_from(), 'foo@bar blah', msg.get_from())
self.assertEqual(msg.get_from(), 'foo@bar blah')
self.assertEqual(msg.get_unixfrom(), 'From foo@bar blah')

def test_from(self):
# Get and set "From " line
msg = mailbox.mboxMessage(_sample_message)
self._check_from(msg)
self.assertIsNone(msg.get_unixfrom())
msg.set_from('foo bar')
self.assertEqual(msg.get_from(), 'foo bar')
self.assertIsNone(msg.get_unixfrom())
msg.set_from('foo@bar', True)
self._check_from(msg, 'foo@bar')
self.assertIsNone(msg.get_unixfrom())
msg.set_from('blah@temp', time.localtime())
self._check_from(msg, 'blah@temp')
self.assertIsNone(msg.get_unixfrom())

def test_flags(self):
# Use get_flags(), set_flags(), add_flag(), remove_flag()
Expand Down Expand Up @@ -1868,6 +1873,7 @@ def test_maildir_to_mboxmmdf(self):
self.assertEqual(msg.get_flags(), result)
self.assertEqual(msg.get_from(), 'MAILER-DAEMON %s' %
time.asctime(time.gmtime(0.0)))
self.assertIsNone(msg.get_unixfrom())
msg_maildir.set_subdir('cur')
self.assertEqual(class_(msg_maildir).get_flags(), 'RODFA')

Expand Down Expand Up @@ -1916,10 +1922,12 @@ def test_mboxmmdf_to_mboxmmdf(self):
msg_mboxMMDF = class_(_sample_message)
msg_mboxMMDF.set_flags('RODFA')
msg_mboxMMDF.set_from('foo@bar')
self.assertIsNone(msg_mboxMMDF.get_unixfrom())
for class2_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg2 = class2_(msg_mboxMMDF)
self.assertEqual(msg2.get_flags(), 'RODFA')
self.assertEqual(msg2.get_from(), 'foo@bar')
self.assertIsNone(msg2.get_unixfrom())

def test_mboxmmdf_to_mh(self):
# Convert mboxMessage and MMDFMessage to MHMessage
Expand Down
0