[Checkins] SVN: persistent/trunk/ Rename 'test_pickle.py' to 'cucumbers.py'.
Tres Seaver
cvs-admin at zope.org
Thu Jun 28 22:49:50 UTC 2012
Log message for revision 127156:
Rename 'test_pickle.py' to 'cucumbers.py'.
It no longer contains tests, only examples to be pickled.
Changed:
_U persistent/trunk/
U persistent/trunk/docs/api/pickling.rst
A persistent/trunk/persistent/tests/cucumbers.py
D persistent/trunk/persistent/tests/test_pickle.py
U persistent/trunk/persistent/tests/test_pyPersistence.py
-=-
Modified: persistent/trunk/docs/api/pickling.rst
===================================================================
--- persistent/trunk/docs/api/pickling.rst 2012-06-28 22:49:43 UTC (rev 127155)
+++ persistent/trunk/docs/api/pickling.rst 2012-06-28 22:49:47 UTC (rev 127156)
@@ -7,12 +7,10 @@
.. 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 @@
.. doctest::
- >>> from persistent.tests.test_pickle import Custom
+ >>> from persistent.tests.cucumbers import Custom
>>> x = Custom('x', 'y')
>>> x.__getnewargs__()
@@ -82,7 +80,7 @@
.. 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 @@
.. 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 @@
>>> 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 @@
{'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
Copied: persistent/trunk/persistent/tests/cucumbers.py (from rev 127155, persistent/trunk/persistent/tests/test_pickle.py)
===================================================================
--- persistent/trunk/persistent/tests/cucumbers.py (rev 0)
+++ persistent/trunk/persistent/tests/cucumbers.py 2012-06-28 22:49:47 UTC (rev 127156)
@@ -0,0 +1,98 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+# Example objects for pickling.
+
+from persistent import Persistent
+
+
+def print_dict(d):
+ d = d.items()
+ d.sort()
+ print '{%s}' % (', '.join(
+ [('%r: %r' % (k, v)) for (k, v) in d]
+ ))
+
+def cmpattrs(self, other, *attrs):
+ for attr in attrs:
+ if attr[:3] in ('_v_', '_p_'):
+ continue
+ c = cmp(getattr(self, attr, None), getattr(other, attr, None))
+ if c:
+ return c
+ return 0
+
+class Simple(Persistent):
+ def __init__(self, name, **kw):
+ self.__name__ = name
+ self.__dict__.update(kw)
+ self._v_favorite_color = 'blue'
+ self._p_foo = 'bar'
+
+ def __cmp__(self, other):
+ return cmpattrs(self, other, '__class__', *(self.__dict__.keys()))
+
+class Custom(Simple):
+
+ def __new__(cls, x, y):
+ r = Persistent.__new__(cls)
+ r.x, r.y = x, y
+ return r
+
+ def __init__(self, x, y):
+ self.a = 42
+
+ def __getnewargs__(self):
+ return self.x, self.y
+
+ def __getstate__(self):
+ return self.a
+
+ def __setstate__(self, a):
+ self.a = a
+
+
+class Slotted(Persistent):
+
+ __slots__ = 's1', 's2', '_p_splat', '_v_eek'
+
+ def __init__(self, s1, s2):
+ self.s1, self.s2 = s1, s2
+ self._v_eek = 1
+ self._p_splat = 2
+
+
+class SubSlotted(Slotted):
+
+ __slots__ = 's3', 's4'
+
+ def __init__(self, s1, s2, s3):
+ Slotted.__init__(self, s1, s2)
+ self.s3 = s3
+
+ def __cmp__(self, other):
+ return cmpattrs(self, other, '__class__', 's1', 's2', 's3', 's4')
+
+
+class SubSubSlotted(SubSlotted):
+
+ def __init__(self, s1, s2, s3, **kw):
+ SubSlotted.__init__(self, s1, s2, s3)
+ self.__dict__.update(kw)
+ self._v_favorite_color = 'blue'
+ self._p_foo = 'bar'
+
+ def __cmp__(self, other):
+ return cmpattrs(self, other,
+ '__class__', 's1', 's2', 's3', 's4',
+ *(self.__dict__.keys()))
Deleted: persistent/trunk/persistent/tests/test_pickle.py
===================================================================
--- persistent/trunk/persistent/tests/test_pickle.py 2012-06-28 22:49:43 UTC (rev 127155)
+++ persistent/trunk/persistent/tests/test_pickle.py 2012-06-28 22:49:47 UTC (rev 127156)
@@ -1,98 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-# Example objects for pickling.
-
-from persistent import Persistent
-
-
-def print_dict(d):
- d = d.items()
- d.sort()
- print '{%s}' % (', '.join(
- [('%r: %r' % (k, v)) for (k, v) in d]
- ))
-
-def cmpattrs(self, other, *attrs):
- for attr in attrs:
- if attr[:3] in ('_v_', '_p_'):
- continue
- c = cmp(getattr(self, attr, None), getattr(other, attr, None))
- if c:
- return c
- return 0
-
-class Simple(Persistent):
- def __init__(self, name, **kw):
- self.__name__ = name
- self.__dict__.update(kw)
- self._v_favorite_color = 'blue'
- self._p_foo = 'bar'
-
- def __cmp__(self, other):
- return cmpattrs(self, other, '__class__', *(self.__dict__.keys()))
-
-class Custom(Simple):
-
- def __new__(cls, x, y):
- r = Persistent.__new__(cls)
- r.x, r.y = x, y
- return r
-
- def __init__(self, x, y):
- self.a = 42
-
- def __getnewargs__(self):
- return self.x, self.y
-
- def __getstate__(self):
- return self.a
-
- def __setstate__(self, a):
- self.a = a
-
-
-class Slotted(Persistent):
-
- __slots__ = 's1', 's2', '_p_splat', '_v_eek'
-
- def __init__(self, s1, s2):
- self.s1, self.s2 = s1, s2
- self._v_eek = 1
- self._p_splat = 2
-
-
-class SubSlotted(Slotted):
-
- __slots__ = 's3', 's4'
-
- def __init__(self, s1, s2, s3):
- Slotted.__init__(self, s1, s2)
- self.s3 = s3
-
- def __cmp__(self, other):
- return cmpattrs(self, other, '__class__', 's1', 's2', 's3', 's4')
-
-
-class SubSubSlotted(SubSlotted):
-
- def __init__(self, s1, s2, s3, **kw):
- SubSlotted.__init__(self, s1, s2, s3)
- self.__dict__.update(kw)
- self._v_favorite_color = 'blue'
- self._p_foo = 'bar'
-
- def __cmp__(self, other):
- return cmpattrs(self, other,
- '__class__', 's1', 's2', 's3', 's4',
- *(self.__dict__.keys()))
Modified: persistent/trunk/persistent/tests/test_pyPersistence.py
===================================================================
--- persistent/trunk/persistent/tests/test_pyPersistence.py 2012-06-28 22:49:43 UTC (rev 127155)
+++ persistent/trunk/persistent/tests/test_pyPersistence.py 2012-06-28 22:49:47 UTC (rev 127156)
@@ -826,7 +826,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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))
More information about the checkins
mailing list