summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py26
-rw-r--r--Lib/test/test_email/test_headerregistry.py20
2 files changed, 46 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index f7e8074..dd1af99 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -1805,6 +1805,32 @@ class TestParser(TestParserMixin, TestEmailBase):
self.assertIsNone(name_addr.route)
self.assertEqual(name_addr.addr_spec, 'dinsdale@example.com')
+ def test_get_name_addr_ending_with_dot_without_space(self):
+ name_addr = self._test_get_x(parser.get_name_addr,
+ 'John X.<jxd@example.com>',
+ 'John X.<jxd@example.com>',
+ '"John X."<jxd@example.com>',
+ [errors.ObsoleteHeaderDefect],
+ '')
+ self.assertEqual(name_addr.display_name, 'John X.')
+ self.assertEqual(name_addr.local_part, 'jxd')
+ self.assertEqual(name_addr.domain, 'example.com')
+ self.assertIsNone(name_addr.route)
+ self.assertEqual(name_addr.addr_spec, 'jxd@example.com')
+
+ def test_get_name_addr_starting_with_dot(self):
+ name_addr = self._test_get_x(parser.get_name_addr,
+ '. Doe <jxd@example.com>',
+ '. Doe <jxd@example.com>',
+ '". Doe" <jxd@example.com>',
+ [errors.InvalidHeaderDefect, errors.ObsoleteHeaderDefect],
+ '')
+ self.assertEqual(name_addr.display_name, '. Doe')
+ self.assertEqual(name_addr.local_part, 'jxd')
+ self.assertEqual(name_addr.domain, 'example.com')
+ self.assertIsNone(name_addr.route)
+ self.assertEqual(name_addr.addr_spec, 'jxd@example.com')
+
def test_get_name_addr_with_route(self):
name_addr = self._test_get_x(parser.get_name_addr,
'"Roy.A.Bear" <@two.example.com: dinsdale@example.com>',
diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py
index 25347ef..bb7ca8d 100644
--- a/Lib/test/test_email/test_headerregistry.py
+++ b/Lib/test/test_email/test_headerregistry.py
@@ -1237,6 +1237,26 @@ class TestAddressHeader(TestHeaderBase):
'example.com',
None),
+ 'name_ending_with_dot_without_space':
+ ('John X.<jxd@example.com>',
+ [errors.ObsoleteHeaderDefect],
+ '"John X." <jxd@example.com>',
+ 'John X.',
+ 'jxd@example.com',
+ 'jxd',
+ 'example.com',
+ None),
+
+ 'name_starting_with_dot':
+ ('. Doe <jxd@example.com>',
+ [errors.InvalidHeaderDefect, errors.ObsoleteHeaderDefect],
+ '". Doe" <jxd@example.com>',
+ '. Doe',
+ 'jxd@example.com',
+ 'jxd',
+ 'example.com',
+ None),
+
}
# XXX: Need many more examples, and in particular some with names in