bpo-37685: Use singletons ALWAYS_EQ and NEVER_EQ in more tests. (GH-15167)

This commit is contained in:
Serhiy Storchaka 2019-08-08 08:43:18 +03:00 committed by GitHub
parent 662db125cd
commit 7d44e7a456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 57 deletions

View file

@ -9,6 +9,7 @@ from enum import Enum, IntEnum, EnumMeta, Flag, IntFlag, unique, auto
from io import StringIO
from pickle import dumps, loads, PicklingError, HIGHEST_PROTOCOL
from test import support
from test.support import ALWAYS_EQ
from datetime import timedelta
@ -1509,13 +1510,10 @@ class TestEnum(unittest.TestCase):
self.assertEqual(list(map(int, Color)), [1, 2, 3])
def test_equality(self):
class AlwaysEqual:
def __eq__(self, other):
return True
class OrdinaryEnum(Enum):
a = 1
self.assertEqual(AlwaysEqual(), OrdinaryEnum.a)
self.assertEqual(OrdinaryEnum.a, AlwaysEqual())
self.assertEqual(ALWAYS_EQ, OrdinaryEnum.a)
self.assertEqual(OrdinaryEnum.a, ALWAYS_EQ)
def test_ordered_mixin(self):
class OrderedEnum(Enum):