[3.10] bpo-44559: [Enum] revert enum module to 3.9 (GH-27010)

* [Enum] revert enum module to 3.9
This commit is contained in:
Ethan Furman 2021-07-03 21:08:42 -07:00 committed by GitHub
parent 000b9e803a
commit 9bf7c2d638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 1790 additions and 4872 deletions

View file

@ -1466,23 +1466,22 @@ class UnicodeTest(string_tests.CommonTest,
PI = 3.1415926
class Int(enum.IntEnum):
IDES = 15
class Str(enum.StrEnum):
# StrEnum uses the value and not the name for %s etc.
class Str(str, enum.Enum):
ABC = 'abc'
# Testing Unicode formatting strings...
self.assertEqual("%s, %s" % (Str.ABC, Str.ABC),
'abc, abc')
'Str.ABC, Str.ABC')
self.assertEqual("%s, %s, %d, %i, %u, %f, %5.2f" %
(Str.ABC, Str.ABC,
Int.IDES, Int.IDES, Int.IDES,
Float.PI, Float.PI),
'abc, abc, 15, 15, 15, 3.141593, 3.14')
'Str.ABC, Str.ABC, 15, 15, 15, 3.141593, 3.14')
# formatting jobs delegated from the string implementation:
self.assertEqual('...%(foo)s...' % {'foo':Str.ABC},
'...abc...')
'...Str.ABC...')
self.assertEqual('...%(foo)s...' % {'foo':Int.IDES},
'...IDES...')
'...Int.IDES...')
self.assertEqual('...%(foo)i...' % {'foo':Int.IDES},
'...15...')
self.assertEqual('...%(foo)d...' % {'foo':Int.IDES},