Submitted by : Simon Michael at: 2007-04-07T17:55:22+00:00 (14 years ago)
Name :
Category : Severity : Status :
Optional subject :  
Optional comment :

(new) can't commit in zwiki unit tests --Simon Michael, Sat, 07 Apr 2007 17:55:26 +0000 reply

ZopeTestCase? supports committing a zodb savepoint, which would set up _p_jar and allow us to test page history. In Zwiki unit tests though, it complains; maybe this is something we can fix ?

(Pdb) transaction.savepoint(1)
*** TypeError: can't pickle file objects
(Pdb) transaction.commit(1)
/zope1/Products/ZWiki/ DeprecationWarning: This will be removed in ZODB 3.7:
subtransactions are deprecated; use transaction.savepoint() instead of transaction.commit(1)
  from testsupport import *
*** TransactionFailedError: An operation previously failed, with traceback:

 File "/zope-2.10/bin/", line 117, in ?
 File "/zope-2.10/lib/python/zope/testing/", line 271, in run
   failed = not run_with_options(options)
 File "/zope-2.10/lib/python/zope/testing/", line 410, in run_with_options
   ran += run_tests(options, tests, 'unit', failures, errors)
 File "/zope-2.10/lib/python/zope/testing/", line 540, in run_tests
 File "/zope-2.10/lib/python/Testing/ZopeTestCase/", line 98, in __call__
 File "/zope1/Products/ZWiki/", line 79, in test_revertEditsEverywhereBy
 File "", line 48, in trace_dispatch
   return self.dispatch_line(frame)
 File "", line 66, in dispatch_line
 File "", line 135, in user_line
   self.interaction(frame, None)
 File "", line 158, in interaction
 File "", line 142, in cmdloop
   stop = self.onecmd(line)
 File "", line 218, in onecmd
   return self.default(line)
 File "", line 167, in default
   exec code in globals, locals
 File "<stdin>", line 1, in ?
 File "/zope-2.10/lib/python/transaction/", line 110, in savepoint
   return self.get().savepoint(optimistic)
 File "/zope-2.10/lib/python/transaction/", line 312, in savepoint
   self._saveAndRaiseCommitishError() # reraises!
 File "/zope-2.10/lib/python/transaction/", line 422, in _saveAndRaiseCommitishError
   t, v, tb = self._saveAndGetCommitishError()
 File "/zope-2.10/lib/python/transaction/", line 309, in savepoint
   savepoint = Savepoint(self, optimistic, *self._resources)
 File "/zope-2.10/lib/python/transaction/", line 737, in __init__
   savepoint = savepoint()
 File "/zope-2.10/lib/python/ZODB/", line 1034, in savepoint
 File "/zope-2.10/lib/python/ZODB/", line 543, in _commit
   self._store_objects(ObjectWriter(obj), transaction)
 File "/zope-2.10/lib/python/ZODB/", line 570, in _store_objects
   p = writer.serialize(obj)  # This calls __getstate__ of obj
 File "/zope-2.10/lib/python/ZODB/", line 407, in serialize
   return self._dump(meta, obj.__getstate__())
 File "/zope-2.10/lib/python/ZODB/", line 416, in _dump
 File "", line 69, in _reduce_ex
   raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle file objects

... --simon, Sat, 07 Apr 2007 18:09:44 +0000 reply

Category: => general Severity: normal => wishlist Status: => open

News: It's probably DemoStorage? at fault --betabug, Sun, 15 Apr 2007 15:24:17 +0000 reply

Interesting comment in OFS/tests/

# set up a zodb
# we can't use DemoStorage here 'cos it doesn't support History

I think we've got the same problem in Zwiki's tests wherever we hit on zodb history when testing. In fact there are two problems:

First we replace ZTC's REQUEST with our own mock request:

# our mock request seems a bit more useful than ZTC's
#self.request =
self.request = = MockRequest()

When I commented this out in a (new) test file I made, I was able to commit transactions withouth the above error.

Second, after I got transactions to work, I tried to test the /diff method, but ran into trouble, because our history() method (which basically calls Zope's manage_change_history) returns () - an empty tupble. This happens in manage_change_history (OFS/, where we hit on the following lines:

r=self._p_jar.db().history(self._p_oid, None, last)
if r is None:
    # storage doesn't support history
    return ()

I guess to properly test our own history behaviour we will have to make extra tests along the line of OFS/tests/

fixed in darcs --simon, Sat, 28 Apr 2007 01:58:59 +0000 reply

Status: open => closed

Fixed by recent commits, I believe (ZWikiPage.__getstate__ omits the REQUEST from pickling).