diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-08 08:42:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-08 08:42:54 +0300 |
commit | 662db125cddbca1db68116c547c290eb3943d98e (patch) | |
tree | 06151487dbe4493ef173dd8cc378f4b6cf5c0e4a /Lib/test/test_email/test_headerregistry.py | |
parent | 4c69be22df3852f17873a74d015528d9a8ae92d6 (diff) | |
download | cpython-662db125cddbca1db68116c547c290eb3943d98e.tar.gz cpython-662db125cddbca1db68116c547c290eb3943d98e.zip |
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
Diffstat (limited to 'Lib/test/test_email/test_headerregistry.py')
-rw-r--r-- | Lib/test/test_email/test_headerregistry.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py index 5d9b3576d30..4758f4b1c52 100644 --- a/Lib/test/test_email/test_headerregistry.py +++ b/Lib/test/test_email/test_headerregistry.py @@ -7,6 +7,7 @@ from email.message import Message from test.test_email import TestEmailBase, parameterize from email import headerregistry from email.headerregistry import Address, Group +from test.support import ALWAYS_EQ DITTO = object() @@ -1525,6 +1526,24 @@ class TestAddressAndGroup(TestEmailBase): self.assertEqual(m['to'], 'foo bar:;') self.assertEqual(m['to'].addresses, g.addresses) + def test_address_comparison(self): + a = Address('foo', 'bar', 'example.com') + self.assertEqual(Address('foo', 'bar', 'example.com'), a) + self.assertNotEqual(Address('baz', 'bar', 'example.com'), a) + self.assertNotEqual(Address('foo', 'baz', 'example.com'), a) + self.assertNotEqual(Address('foo', 'bar', 'baz'), a) + self.assertFalse(a == object()) + self.assertTrue(a == ALWAYS_EQ) + + def test_group_comparison(self): + a = Address('foo', 'bar', 'example.com') + g = Group('foo bar', [a]) + self.assertEqual(Group('foo bar', (a,)), g) + self.assertNotEqual(Group('baz', [a]), g) + self.assertNotEqual(Group('foo bar', []), g) + self.assertFalse(g == object()) + self.assertTrue(g == ALWAYS_EQ) + class TestFolding(TestHeaderBase): |