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
bcea6039
Commit
bcea6039
authored
Nov 24, 2013
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selectively re-enable framing tests
parent
82dbf7cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
Lib/test/pickletester.py
Lib/test/pickletester.py
+19
-11
Lib/test/test_pickletools.py
Lib/test/test_pickletools.py
+2
-0
No files found.
Lib/test/pickletester.py
View file @
bcea6039
...
...
@@ -438,6 +438,8 @@ def create_data():
class
AbstractPickleTests
(
unittest
.
TestCase
):
# Subclass must define self.dumps, self.loads.
optimized
=
False
_testdata
=
create_data
()
def
setUp
(
self
):
...
...
@@ -1334,13 +1336,16 @@ class AbstractPickleTests(unittest.TestCase):
self
.
assertEqual
(
obj
,
unpickled
)
# Test the framing heuristic is sane,
# assuming a given frame size target.
# XXX Assumptions here are wrong when the pickle are optimized
# bytes_per_frame = (len(pickled) /
# count_opcode(pickle.FRAME, pickled))
# self.assertGreater(bytes_per_frame,
# self.FRAME_SIZE_TARGET / 2)
# self.assertLessEqual(bytes_per_frame,
# self.FRAME_SIZE_TARGET * 1)
if
self
.
optimized
:
# These assumptions are currently invalid for optimized
# pickles (see e.g. issue19754).
continue
bytes_per_frame
=
(
len
(
pickled
)
/
count_opcode
(
pickle
.
FRAME
,
pickled
))
self
.
assertGreater
(
bytes_per_frame
,
self
.
FRAME_SIZE_TARGET
/
2
)
self
.
assertLessEqual
(
bytes_per_frame
,
self
.
FRAME_SIZE_TARGET
*
1
)
def
test_framing_large_objects
(
self
):
N
=
1024
*
1024
...
...
@@ -1350,10 +1355,13 @@ class AbstractPickleTests(unittest.TestCase):
pickled
=
self
.
dumps
(
obj
,
proto
)
unpickled
=
self
.
loads
(
pickled
)
self
.
assertEqual
(
obj
,
unpickled
)
# At least one frame was emitted per large bytes object.
# XXX Assumptions here are wrong when the pickle are optimized
# n_frames = count_opcode(pickle.FRAME, pickled)
# self.assertGreaterEqual(n_frames, len(obj))
n_frames
=
count_opcode
(
pickle
.
FRAME
,
pickled
)
if
self
.
optimized
:
# At least one frame was emitted (see issue19754).
self
.
assertGreaterEqual
(
n_frames
,
1
)
else
:
# At least one frame was emitted per large bytes object.
self
.
assertGreaterEqual
(
n_frames
,
len
(
obj
))
def
test_optional_frames
(
self
):
if
pickle
.
HIGHEST_PROTOCOL
<
4
:
...
...
Lib/test/test_pickletools.py
View file @
bcea6039
...
...
@@ -6,6 +6,8 @@ from test.pickletester import AbstractPickleModuleTests
class
OptimizedPickleTests
(
AbstractPickleTests
,
AbstractPickleModuleTests
):
optimized
=
True
def
dumps
(
self
,
arg
,
proto
=
None
):
return
pickletools
.
optimize
(
pickle
.
dumps
(
arg
,
proto
))
...
...
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