Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e50e7802
Commit
e50e7802
authored
Mar 31, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23611: Fixed enums pickling tests. Now all picklings work with all
protocols.
parent
5236e318
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
Lib/test/test_enum.py
Lib/test/test_enum.py
+7
-15
No files found.
Lib/test/test_enum.py
View file @
e50e7802
...
@@ -66,18 +66,14 @@ try:
...
@@ -66,18 +66,14 @@ try:
except
Exception
:
except
Exception
:
pass
pass
def
test_pickle_dump_load
(
assertion
,
source
,
target
=
None
,
def
test_pickle_dump_load
(
assertion
,
source
,
target
=
None
):
*
,
protocol
=
(
0
,
HIGHEST_PROTOCOL
)):
start
,
stop
=
protocol
if
target
is
None
:
if
target
is
None
:
target
=
source
target
=
source
for
protocol
in
range
(
start
,
stop
+
1
):
for
protocol
in
range
(
HIGHEST_PROTOCOL
+
1
):
assertion
(
loads
(
dumps
(
source
,
protocol
=
protocol
)),
target
)
assertion
(
loads
(
dumps
(
source
,
protocol
=
protocol
)),
target
)
def
test_pickle_exception
(
assertion
,
exception
,
obj
,
def
test_pickle_exception
(
assertion
,
exception
,
obj
):
*
,
protocol
=
(
0
,
HIGHEST_PROTOCOL
)):
for
protocol
in
range
(
HIGHEST_PROTOCOL
+
1
):
start
,
stop
=
protocol
for
protocol
in
range
(
start
,
stop
+
1
):
with
assertion
(
exception
):
with
assertion
(
exception
):
dumps
(
obj
,
protocol
=
protocol
)
dumps
(
obj
,
protocol
=
protocol
)
...
@@ -575,11 +571,7 @@ class TestEnum(unittest.TestCase):
...
@@ -575,11 +571,7 @@ class TestEnum(unittest.TestCase):
self
.
__class__
.
NestedEnum
=
NestedEnum
self
.
__class__
.
NestedEnum
=
NestedEnum
self
.
NestedEnum
.
__qualname__
=
'%s.NestedEnum'
%
self
.
__class__
.
__name__
self
.
NestedEnum
.
__qualname__
=
'%s.NestedEnum'
%
self
.
__class__
.
__name__
test_pickle_exception
(
test_pickle_dump_load
(
self
.
assertIs
,
self
.
NestedEnum
.
twigs
)
self
.
assertRaises
,
PicklingError
,
self
.
NestedEnum
.
twigs
,
protocol
=
(
0
,
3
))
test_pickle_dump_load
(
self
.
assertIs
,
self
.
NestedEnum
.
twigs
,
protocol
=
(
4
,
HIGHEST_PROTOCOL
))
def
test_pickle_by_name
(
self
):
def
test_pickle_by_name
(
self
):
class
ReplaceGlobalInt
(
IntEnum
):
class
ReplaceGlobalInt
(
IntEnum
):
...
@@ -1096,9 +1088,9 @@ class TestEnum(unittest.TestCase):
...
@@ -1096,9 +1088,9 @@ class TestEnum(unittest.TestCase):
globals
()[
'NEI'
]
=
NEI
globals
()[
'NEI'
]
=
NEI
NI5
=
NamedInt
(
'test'
,
5
)
NI5
=
NamedInt
(
'test'
,
5
)
self
.
assertEqual
(
NI5
,
5
)
self
.
assertEqual
(
NI5
,
5
)
test_pickle_dump_load
(
self
.
assertEqual
,
NI5
,
5
,
protocol
=
(
4
,
4
)
)
test_pickle_dump_load
(
self
.
assertEqual
,
NI5
,
5
)
self
.
assertEqual
(
NEI
.
y
.
value
,
2
)
self
.
assertEqual
(
NEI
.
y
.
value
,
2
)
test_pickle_dump_load
(
self
.
assertIs
,
NEI
.
y
,
protocol
=
(
4
,
4
)
)
test_pickle_dump_load
(
self
.
assertIs
,
NEI
.
y
)
test_pickle_dump_load
(
self
.
assertIs
,
NEI
)
test_pickle_dump_load
(
self
.
assertIs
,
NEI
)
def
test_subclasses_with_reduce
(
self
):
def
test_subclasses_with_reduce
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment