]> granicus.if.org Git - python/commitdiff
test_name_with_dots(): A new test to ensure that we're implementing
authorBarry Warsaw <barry@python.org>
Mon, 30 Dec 2002 16:19:52 +0000 (16:19 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 30 Dec 2002 16:19:52 +0000 (16:19 +0000)
RFC 2822's rules w.r.t. dots in the realname part of address fields.

Lib/email/test/test_email.py

index 61b412a9afe0c46d25fcf35da96558d3c7cc387f..cbcc0df1b11a09017f1f0614dc2c9cf8f21763c5 100644 (file)
@@ -1687,6 +1687,15 @@ class TestMiscellaneous(unittest.TestCase):
         b = 'person@dom.ain'
         self.assertEqual(Utils.parseaddr(Utils.formataddr((a, b))), (a, b))
 
+    def test_name_with_dot(self):
+        x = 'John X. Doe <jxd@example.com>'
+        y = '"John X. Doe" <jxd@example.com>'
+        a, b = ('John X. Doe', 'jxd@example.com')
+        self.assertEqual(Utils.parseaddr(x), (a, b))
+        self.assertEqual(Utils.parseaddr(y), (a, b))
+        # formataddr() quotes the name if there's a dot in it
+        self.assertEqual(Utils.formataddr((a, b)), y)
+
     def test_quote_dump(self):
         self.assertEqual(
             Utils.formataddr(('A Silly; Person', 'person@dom.ain')),