diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-05-12 07:39:32 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-05-12 07:39:32 (GMT) |
commit | 1f364438adf1bcdc89a51af9af526ed9d7b7996d (patch) | |
tree | 2d620f18e63ff8703f4da17d98d0467a40a3c507 /Lib/test/test_enum.py | |
parent | 5787ef621a76dfe225308f0001d60e5e46e9a55f (diff) | |
parent | ea36c941a1b2ad6582a35bc42aa70da9600d2841 (diff) | |
download | cpython-1f364438adf1bcdc89a51af9af526ed9d7b7996d.zip cpython-1f364438adf1bcdc89a51af9af526ed9d7b7996d.tar.gz cpython-1f364438adf1bcdc89a51af9af526ed9d7b7996d.tar.bz2 |
Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r-- | Lib/test/test_enum.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 29cd3cf..b6cb00f 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -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 |