[Checkins] SVN: zope.component/branches/wosc-test-stacking/src/zope/component/ Snapshot: Fix persistence test, so that it actually exercises persitence. Now it breaks, of course.
Wolfgang Schnerring
wosc at wosc.de
Thu Jun 23 08:17:13 EDT 2011
Log message for revision 121969:
Snapshot: Fix persistence test, so that it actually exercises persitence. Now it breaks, of course.
Changed:
U zope.component/branches/wosc-test-stacking/src/zope/component/stackable.py
U zope.component/branches/wosc-test-stacking/src/zope/component/tests.py
-=-
Modified: zope.component/branches/wosc-test-stacking/src/zope/component/stackable.py
===================================================================
--- zope.component/branches/wosc-test-stacking/src/zope/component/stackable.py 2011-06-23 11:18:41 UTC (rev 121968)
+++ zope.component/branches/wosc-test-stacking/src/zope/component/stackable.py 2011-06-23 12:17:12 UTC (rev 121969)
@@ -4,8 +4,9 @@
class StackableBase(object):
- def __init__(self, original):
- self.stack = [original]
+ def __init__(self, original=None):
+ if original is not None:
+ self.stack = [original]
def push(self):
self.stack.append(copy.copy(self.stack[-1]))
Modified: zope.component/branches/wosc-test-stacking/src/zope/component/tests.py
===================================================================
--- zope.component/branches/wosc-test-stacking/src/zope/component/tests.py 2011-06-23 11:18:41 UTC (rev 121968)
+++ zope.component/branches/wosc-test-stacking/src/zope/component/tests.py 2011-06-23 12:17:12 UTC (rev 121969)
@@ -1725,14 +1725,23 @@
def test_is_persistable(self):
import tempfile
import ZODB
- tmpfile = tempfile.NamedTemporaryFile(delete=True)
- root = ZODB.DB(tmpfile.name).open().root()
+ # XXX delete tempfile, or rather, don't use FileStorage at all, use
+ # DemoStorage instead
+ tmpfile = tempfile.NamedTemporaryFile()
+ db = ZODB.DB(tmpfile.name)
+ root = db.open().root()
orig = [1]
stack = zope.component.stackable.stackable(orig)
root['stack'] = stack
zope.component.stackable.push()
stack.append(2)
transaction.commit()
+
+ # force deserialization
+ db.close()
+ db = ZODB.DB(tmpfile.name)
+ root = db.open().root()
+
stack = root['stack']
self.assertEqual([1, 2], stack)
zope.component.stackable.pop()
More information about the checkins
mailing list