diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-05-26 02:53:12 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-05-26 02:53:12 (GMT) |
commit | dcaf2ece6cbd432f8ad71ca2bebc4f79e3b97fbc (patch) | |
tree | 80286278c40e341ebbe0074f450c7ec84deb5399 /Lib/test/test_email | |
parent | b5267631cb2a62088ef12b36abd0317957244c6c (diff) | |
download | cpython-dcaf2ece6cbd432f8ad71ca2bebc4f79e3b97fbc.zip cpython-dcaf2ece6cbd432f8ad71ca2bebc4f79e3b97fbc.tar.gz cpython-dcaf2ece6cbd432f8ad71ca2bebc4f79e3b97fbc.tar.bz2 |
#12586: Fix a small oversight in the new email policy header setting code.
This is a danger of focusing on unit tests: sometimes you forget
to do the integration tests.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test__headerregistry.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__headerregistry.py b/Lib/test/test_email/test__headerregistry.py index 4398e29..23bc5ff 100644 --- a/Lib/test/test_email/test__headerregistry.py +++ b/Lib/test/test_email/test__headerregistry.py @@ -3,6 +3,7 @@ import textwrap import unittest from email import errors from email import policy +from email.message import Message from test.test_email import TestEmailBase from email import _headerregistry # Address and Group are public but I'm not sure where to put them yet. @@ -168,6 +169,12 @@ class TestDateHeader(TestHeaderBase): with self.assertRaises(AttributeError): h.datetime = 'foo' + def test_set_date_header_from_datetime(self): + m = Message(policy=policy.default) + m['Date'] = self.dt + self.assertEqual(m['Date'], self.datestring) + self.assertEqual(m['Date'].datetime, self.dt) + class TestAddressHeader(TestHeaderBase): @@ -625,6 +632,20 @@ class TestAddressAndGroup(TestEmailBase): self.assertEqual(g.addresses, tuple()) self.assertEqual(str(g), 'foo bar:;') + def test_set_message_header_from_address(self): + a = Address('foo', 'bar', 'example.com') + m = Message(policy=policy.default) + m['To'] = a + self.assertEqual(m['to'], 'foo <bar@example.com>') + self.assertEqual(m['to'].addresses, (a,)) + + def test_set_message_header_from_group(self): + g = Group('foo bar') + m = Message(policy=policy.default) + m['To'] = g + self.assertEqual(m['to'], 'foo bar:;') + self.assertEqual(m['to'].addresses, g.addresses) + class TestFolding(TestHeaderBase): @@ -713,5 +734,6 @@ class TestFolding(TestHeaderBase): 'Date: Sat, 02 Feb 2002 17:00:06 -0800\n') + if __name__ == '__main__': unittest.main() |