Skip to content

Commit c7ae712

Browse files
committed
Get enum convert test passing, private API changed in 3.9
1 parent 3dcb97a commit c7ae712

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

py_samples/int_enum_convert.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import enum
2+
from enum import IntEnum as _IntEnum
3+
4+
FOO = 42
5+
BAR = 64
6+
smol = 128
7+
8+
# This private interface changed at some point between 3.7 and 3.9.
9+
convert = _IntEnum._convert if hasattr(_IntEnum, '_convert') else _IntEnum._convert_
10+
11+
converted = convert('Stuff', __name__,
12+
lambda name: name.isupper())
13+
assert converted.__name__ == 'Stuff', repr(converted)
14+
assert converted.FOO.value == 42
15+
assert converted.BAR.value == 64
16+
assert hasattr(converted, 'FOO')
17+
assert not hasattr(converted, 'smol')

py_samples/knownf_int_enum_convert.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)