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
e9ef203e
Commit
e9ef203e
authored
Feb 13, 2003
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a simple NEWOBJ test. This is in the pickle-only part of the
test for now (cPickle can't yet produce NEWOBJ).
parent
c1eea67d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
Lib/test/pickletester.py
Lib/test/pickletester.py
+15
-0
No files found.
Lib/test/pickletester.py
View file @
e9ef203e
...
...
@@ -724,6 +724,16 @@ class AbstractPickleTests(unittest.TestCase):
# XXX along with the references to it in test_pickle.py.
class
TempAbstractPickleTests
(
unittest
.
TestCase
):
def
test_simple_newobj
(
self
):
x
=
object
.
__new__
(
SimpleNewObj
)
# avoid __init__
x
.
abc
=
666
for
proto
in
protocols
:
s
=
self
.
dumps
(
x
,
proto
)
self
.
assertEqual
(
opcode_in_pickle
(
pickle
.
NEWOBJ
,
s
),
proto
>=
2
)
y
=
self
.
loads
(
s
)
# will raise TypeError if __init__ called
self
.
assertEqual
(
y
.
abc
,
666
)
self
.
assertEqual
(
x
.
__dict__
,
y
.
__dict__
)
def
test_newobj_list_slots
(
self
):
x
=
SlotList
([
1
,
2
,
3
])
x
.
foo
=
42
...
...
@@ -771,6 +781,11 @@ myclasses = [MyInt, MyLong, MyFloat,
class
SlotList
(
MyList
):
__slots__
=
[
"foo"
]
class
SimpleNewObj
(
object
):
def
__init__
(
self
,
a
,
b
,
c
):
# raise an error, to make sure this isn't called
raise
TypeError
(
"SimpleNewObj.__init__() didn't expect to get called"
)
class
AbstractPickleModuleTests
(
unittest
.
TestCase
):
def
test_dump_closed_file
(
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