from unittest import TestCase, main from email.headerregistry import Address ''' Bug report for email addresses: Story: I want to create an email address as in the Python doc example https://docs.python.org/3/library/email-examples.html for Python 3.4rc1 and the 3.5 compiled from source. I found two possible reasons: 1) Python bug in headerregistry.py The string resulting from contains extra quotes: str(Address('Foo Example', 'foo@example.com')) --> 'Foo Example <"foo@example.com">' 2) Documentation bug The documentation of headerregistry.Address states: "username and domain may be specified together by using the addr_spec keyword *instead of* the username and domain keywords" However, this is inconsistent with example 19.1.14.1. on https://docs.python.org/3/library/email-examples.html Therefore the first test below fails but the second passes. I run Ubuntu 12. Conclusion: In my opinion, it is more intuitive if the following would work as well: Address('Foo Example', 'foo@example.com') ''' class MailTests(TestCase): def test_address_to_string(self): """Address converts to string but introduces extra quotes --> fail""" address = Address('Foo Example', 'foo@example.com') self.assertEqual(str(address), 'Foo Example ') def test_address_to_string_addr_spec(self): """Address converts to string without extra quotes if addr_spec used""" address = Address('Foo Example', addr_spec='foo@example.com') self.assertEqual(str(address), 'Foo Example ') if __name__ == '__main__': main()