Skip to content

Modernize test_enum by removing unused exception handling #105522

Closed
@sobolevn

Description

@sobolevn

Right now there are places in test_enum that for some reason contain code like

try:
class IntStooges(int, Enum):
LARRY = 1
CURLY = 2
MOE = 3
except Exception as exc:
IntStooges = exc
try:
class FloatStooges(float, Enum):
LARRY = 1.39
CURLY = 2.72
MOE = 3.142596
except Exception as exc:
FloatStooges = exc
try:
class FlagStooges(Flag):
LARRY = 1
CURLY = 2
MOE = 4
BIG = 389
except Exception as exc:
FlagStooges = exc

For some reason we try to catch exceptions that won't ever happen (at least, they never should happen).

But, there are also regular Enums that are defined without any exceptions:

class FlagStoogesWithZero(Flag):
NOFLAG = 0
LARRY = 1
CURLY = 2
MOE = 4
BIG = 389
class IntFlagStooges(IntFlag):
LARRY = 1
CURLY = 2
MOE = 4
BIG = 389
class IntFlagStoogesWithZero(IntFlag):
NOFLAG = 0
LARRY = 1
CURLY = 2
MOE = 4
BIG = 389
# for pickle test and subclass tests
class Name(StrEnum):
BDFL = 'Guido van Rossum'
FLUFL = 'Barry Warsaw'

This is an artifact of 10+ age: 6b3d64a#diff-8467f9fbbff81abf26d87a8dbbf0e0c866157971948010e48cc73539251a9e4cR14

I propose to remove this and backport this PR to all supported Python versions.
PR will be available quite soon :)

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions