8000 bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ by jason-curtis · Pull Request #14545 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ #14545 8000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
one more test to fill out the grid
  • Loading branch information
jason-curtis committed Jul 2, 2019
commit e54d60d98acfc1e93dc9f49f32782e2feb855e2c
9 changes: 9 additions & 0 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ def __str__(self):
self.assertEqual(str(EnumWithStrOverrides.one), 'Str!')
self.assertEqual('{}'.format(EnumWithStrOverrides.one), 'Str!')

def test_format_override_enum(self):
class EnumWithFormatOverride(float, Enum):
one = 1.0
two = 2.0
def __format__(self, spec):
return 'Format!!'
self.assertEqual(str(EnumWithFormatOverride.one), 'EnumWithFormatOverride.one')
self.assertEqual('{}'.format(EnumWithFormatOverride.one), 'Format!!')

def test_str_and_format_override_enum(self):
class EnumWithStrFormatOverrides(Enum):
one = auto()
Expand Down
0