Commit 49919d31 authored by Godefroid Chapelle's avatar Godefroid Chapelle

test for POSKeyError during transaction commit

see https://github.com/zopefoundation/ZODB/issues/16
parent 41908b25
......@@ -17,6 +17,8 @@ from persistent.mapping import PersistentMapping
from ZODB.POSException import ReadConflictError
from ZODB.POSException import TransactionFailedError
import Acquisition
from BTrees.OOBTree import OOBTree
import transaction
import unittest
import ZODB
......@@ -24,9 +26,19 @@ import ZODB.FileStorage
import ZODB.MappingStorage
import ZODB.tests.util
class P(Persistent):
pass
class AcqImplicitP(P, Acquisition.Implicit):
pass
class AcqImplicitOOBTree(OOBTree, Acquisition.Implicit):
pass
class ZODBTests(ZODB.tests.util.TestCase):
def setUp(self):
......@@ -328,6 +340,28 @@ class ZODBTests(ZODB.tests.util.TestCase):
cn.close()
def checkSavepointRollbackAndReadCurrent(self):
'''
savepoint rollback after readcurrent was called on a new object
should not raise POSKeyError
'''
cn = self._db.open()
try:
transaction.begin()
root = cn.root()
added_before_savepoint = AcqImplicitP()
root['added_before_savepoint'] = added_before_savepoint
sp = transaction.savepoint()
added_before_savepoint.btree = new_btree = AcqImplicitOOBTree()
cn.add(new_btree)
new_btree['change_to_trigger_read_current'] = AcqImplicitP()
sp.rollback()
transaction.commit()
self.assertTrue('added_before_savepoint' in root)
finally:
transaction.abort()
cn.close()
def checkFailingSavepointSticks(self):
cn = self._db.open()
rt = cn.root()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment