Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
db4d354e
Commit
db4d354e
authored
Jun 28, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'test_pickle.py' to 'cucumbers.py'.
It no longer contains tests, only examples to be pickled.
parent
871686e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
22 deletions
+19
-22
docs/api/pickling.rst
docs/api/pickling.rst
+13
-16
persistent/tests/cucumbers.py
persistent/tests/cucumbers.py
+0
-0
persistent/tests/test_pyPersistence.py
persistent/tests/test_pyPersistence.py
+6
-6
No files found.
docs/api/pickling.rst
View file @
db4d354e
...
...
@@ -7,12 +7,10 @@ machinery happy:
.. doctest::
>>> import pickle
>>> from persistent.tests.
test_pickle
import Simple
>>> from persistent.tests.
test_pickle
import print_dict
>>> from persistent.tests.
cucumbers
import Simple
>>> from persistent.tests.
cucumbers
import print_dict
>>> x = Simple('x', aaa=1, bbb='foo')
>>> print_dict(x.__dict__)
{'__name__': 'x', 'aaa': 1, 'bbb': 'foo'}
>>> print_dict(x.__getstate__())
{'__name__': 'x', 'aaa': 1, 'bbb': 'foo'}
...
...
@@ -49,7 +47,7 @@ by overriding :meth:`__getnewargs__`, :meth:`__getstate__` and
.. doctest::
>>> from persistent.tests.
test_pickle
import Custom
>>> from persistent.tests.
cucumbers
import Custom
>>> x = Custom('x', 'y')
>>> x.__getnewargs__()
...
...
@@ -82,7 +80,7 @@ ignores any slots which map onto the "persistent" namespace (prefixed with
.. doctest::
>>> import copy_reg
>>> from persistent.tests.
test_pickle
import SubSlotted
>>> from persistent.tests.
cucumbers
import SubSlotted
>>> x = SubSlotted('x', 'y', 'z')
Note that we haven't yet assiged a value to the ``s4`` attribute:
...
...
@@ -131,7 +129,7 @@ themselves:
.. doctest::
>>> from persistent.tests.
test_pickle
import SubSubSlotted
>>> from persistent.tests.
cucumbers
import SubSubSlotted
>>> x = SubSubSlotted('x', 'y', 'z')
>>> d, s = x.__getstate__()
...
...
@@ -142,13 +140,13 @@ themselves:
>>> import pickle
>>> pickle.loads(pickle.dumps(x)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 0)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 1)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 2)) == x
1
True
>>> x.s4 = 'spam'
>>> x.foo = 'bar'
...
...
@@ -161,11 +159,10 @@ themselves:
{'s1': 'x', 's2': 'y', 's3': 'z', 's4': 'spam'}
>>> pickle.loads(pickle.dumps(x)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 0)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 1)) == x
1
True
>>> pickle.loads(pickle.dumps(x, 2)) == x
1
True
persistent/tests/
test_pickle
.py
→
persistent/tests/
cucumbers
.py
View file @
db4d354e
File moved
persistent/tests/test_pyPersistence.py
View file @
db4d354e
...
...
@@ -826,7 +826,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_simple
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
Simple
from
persistent.tests.
cucumbers
import
Simple
inst
=
Simple
(
'testing'
)
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
self
.
assertEqual
(
copy
,
inst
)
...
...
@@ -837,7 +837,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_w_getnewargs_and_getstate
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
Custom
from
persistent.tests.
cucumbers
import
Custom
inst
=
Custom
(
'x'
,
'y'
)
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
self
.
assertEqual
(
copy
,
inst
)
...
...
@@ -848,7 +848,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_w_slots_missing_slot
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
SubSlotted
from
persistent.tests.
cucumbers
import
SubSlotted
inst
=
SubSlotted
(
'x'
,
'y'
,
'z'
)
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
self
.
assertEqual
(
copy
,
inst
)
...
...
@@ -859,7 +859,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_w_slots_filled_slot
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
SubSlotted
from
persistent.tests.
cucumbers
import
SubSlotted
inst
=
SubSlotted
(
'x'
,
'y'
,
'z'
)
inst
.
s4
=
'a'
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
...
...
@@ -871,7 +871,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_w_slots_and_empty_dict
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
SubSubSlotted
from
persistent.tests.
cucumbers
import
SubSubSlotted
inst
=
SubSubSlotted
(
'x'
,
'y'
,
'z'
)
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
self
.
assertEqual
(
copy
,
inst
)
...
...
@@ -882,7 +882,7 @@ class _Persistent_Base(object):
def
test_pickle_roundtrip_w_slots_and_filled_dict
(
self
):
import
pickle
# XXX s.b. 'examples'
from
persistent.tests.
test_pickle
import
SubSubSlotted
from
persistent.tests.
cucumbers
import
SubSubSlotted
inst
=
SubSubSlotted
(
'x'
,
'y'
,
'z'
,
foo
=
'bar'
,
baz
=
'bam'
)
inst
.
s4
=
'a'
copy
=
pickle
.
loads
(
pickle
.
dumps
(
inst
))
...
...
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