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
fc27375d
Commit
fc27375d
authored
Mar 02, 2003
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_load_from_canned_string(): Created a DATA2 string to test a canned
proto 2 pickle too.
parent
563389fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
2 deletions
+66
-2
Lib/test/pickletester.py
Lib/test/pickletester.py
+66
-2
No files found.
Lib/test/pickletester.py
View file @
fc27375d
...
...
@@ -88,7 +88,6 @@ class use_metaclass(object):
# DATA0 .. DATA2 are the pickles we expect under the various protocols, for
# the object returned by create_data().
# XXX DATA2 doesn't exist yet, as it's not fully implemented in cPickle.
# break into multiple strings to avoid confusing font-lock-mode
DATA0
=
"""(lp1
...
...
@@ -276,6 +275,71 @@ DATA1_DIS = """\
highest protocol among opcodes = 1
"""
DATA2
=
(
'
\
x80
\
x02
]q
\
x01
(K
\
x00
\
x8a
\
x01
\
x01
G@
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
'c__builtin__
\
n
complex
\
n
q
\
x02
G@
\
x08
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
G
\
x00
'
'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x86
Rq
\
x03
K
\
x01
J
\
xff
\
xff
\
xff
\
xff
K'
'
\
xff
J
\
x01
\
xff
\
xff
\
xff
J
\
x00
\
xff
\
xff
\
xff
M
\
xff
\
xff
J
\
x01
\
x00
\
xff
\
xff
'
'J
\
x00
\
x00
\
xff
\
xff
J
\
xff
\
xff
\
xff
\
x7f
J
\
x01
\
x00
\
x00
\
x80
J
\
x00
\
x00
\
x00
'
'
\
x80
(U
\
x03
abcq
\
x04
h
\
x04
(c__main__
\
n
C
\
n
q
\
x05
oq
\
x06
}q
\
x07
(U
\
x03
foo'
'q
\
x08
K
\
x01
U
\
x03
barq
\
t
K
\
x02
ubh
\
x06
tq
\
n
h
\
n
K
\
x05
e.'
)
# Disassembly of DATA2.
DATA2_DIS
=
"""
\
0:
\
x80
PROTO 2
2: ] EMPTY_LIST
3: q BINPUT 1
5: ( MARK
6: K BININT1 0
8:
\
x8a
LONG1 1L
11: G BINFLOAT 2.0
20: c GLOBAL '__builtin__ complex'
41: q BINPUT 2
43: G BINFLOAT 3.0
52: G BINFLOAT 0.0
61:
\
x86
TUPLE2
62: R REDUCE
63: q BINPUT 3
65: K BININT1 1
67: J BININT -1
72: K BININT1 255
74: J BININT -255
79: J BININT -256
84: M BININT2 65535
87: J BININT -65535
92: J BININT -65536
97: J BININT 2147483647
102: J BININT -2147483647
107: J BININT -2147483648
112: ( MARK
113: U SHORT_BINSTRING 'abc'
118: q BINPUT 4
120: h BINGET 4
122: ( MARK
123: c GLOBAL '__main__ C'
135: q BINPUT 5
137: o OBJ (MARK at 122)
138: q BINPUT 6
140: } EMPTY_DICT
141: q BINPUT 7
143: ( MARK
144: U SHORT_BINSTRING 'foo'
149: q BINPUT 8
151: K BININT1 1
153: U SHORT_BINSTRING 'bar'
158: q BINPUT 9
160: K BININT1 2
162: u SETITEMS (MARK at 143)
163: b BUILD
164: h BINGET 6
166: t TUPLE (MARK at 112)
167: q BINPUT 10
169: h BINGET 10
171: K BININT1 5
173: e APPENDS (MARK at 5)
174: . STOP
highest protocol among opcodes = 2
"""
def
create_data
():
c
=
C
()
c
.
foo
=
1
...
...
@@ -333,7 +397,7 @@ class AbstractPickleTests(unittest.TestCase):
def
test_load_from_canned_string
(
self
):
expected
=
self
.
_testdata
for
canned
in
DATA0
,
DATA1
:
for
canned
in
DATA0
,
DATA1
,
DATA2
:
got
=
self
.
loads
(
canned
)
self
.
assertEqual
(
expected
,
got
)
...
...
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