mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.
This commit is contained in:
commit
1f364438ad
6 changed files with 56 additions and 21 deletions
|
@ -564,6 +564,18 @@ class TestEnum(unittest.TestCase):
|
|||
self.assertEqual([k for k,v in WeekDay.__members__.items()
|
||||
if v.name != k], ['TEUSDAY', ])
|
||||
|
||||
def test_intenum_from_bytes(self):
|
||||
self.assertIs(IntStooges.from_bytes(b'\x00\x03', 'big'), IntStooges.MOE)
|
||||
with self.assertRaises(ValueError):
|
||||
IntStooges.from_bytes(b'\x00\x05', 'big')
|
||||
|
||||
def test_floatenum_fromhex(self):
|
||||
h = float.hex(FloatStooges.MOE.value)
|
||||
self.assertIs(FloatStooges.fromhex(h), FloatStooges.MOE)
|
||||
h = float.hex(FloatStooges.MOE.value + 0.01)
|
||||
with self.assertRaises(ValueError):
|
||||
FloatStooges.fromhex(h)
|
||||
|
||||
def test_pickle_enum(self):
|
||||
if isinstance(Stooges, Exception):
|
||||
raise Stooges
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue