summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-10 23:37:27 (GMT)
committerGitHub <noreply@github.com>2021-06-10 23:37:27 (GMT)
commitb613132861839b6d05b67138842b579e1af29f9c (patch)
tree383e8ffae45f7cd31af1196f4dea0fed693a6aea /Lib/test
parent3e137426de3e6a37622b2ca61207b1323fdea11f (diff)
downloadcpython-b613132861839b6d05b67138842b579e1af29f9c.zip
cpython-b613132861839b6d05b67138842b579e1af29f9c.tar.gz
cpython-b613132861839b6d05b67138842b579e1af29f9c.tar.bz2
bpo-44342: [Enum] changed pickling from by-value to by-name (GH-26658) (GH-26660)
by-value lookups could fail on complex enums, necessitating a check for __reduce__ and possibly sabotaging the final enum; by-name lookups should never fail, and sabotaging is no longer necessary for class-based enum creation. (cherry picked from commit 62f1d2b3d7dda99598d053e10b785c463fdcf591) Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_enum.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 40794e3..9a7882b 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -830,7 +830,7 @@ class TestEnum(unittest.TestCase):
class ReplaceGlobalInt(IntEnum):
ONE = 1
TWO = 2
- ReplaceGlobalInt.__reduce_ex__ = enum._reduce_ex_by_name
+ ReplaceGlobalInt.__reduce_ex__ = enum._reduce_ex_by_global_name
for proto in range(HIGHEST_PROTOCOL):
self.assertEqual(ReplaceGlobalInt.TWO.__reduce_ex__(proto), 'TWO')
@@ -1527,10 +1527,10 @@ class TestEnum(unittest.TestCase):
NI5 = NamedInt('test', 5)
self.assertEqual(NI5, 5)
self.assertEqual(NEI.y.value, 2)
- test_pickle_exception(self.assertRaises, TypeError, NEI.x)
- test_pickle_exception(self.assertRaises, PicklingError, NEI)
+ test_pickle_dump_load(self.assertIs, NEI.y)
+ test_pickle_dump_load(self.assertIs, NEI)
- def test_subclasses_without_direct_pickle_support_using_name(self):
+ def test_subclasses_with_direct_pickle_support(self):
class NamedInt(int):
__qualname__ = 'NamedInt'
def __new__(cls, *args):