Commit 3aa42526 authored by Godefroid Chapelle's avatar Godefroid Chapelle

Add test for fix POSKeyError during commit after savepoint rollback

see https://github.com/zopefoundation/ZODB/issues/16
parent 9e84a83a
...@@ -17,6 +17,7 @@ from ZODB.POSException import ReadConflictError ...@@ -17,6 +17,7 @@ from ZODB.POSException import ReadConflictError
from ZODB.POSException import TransactionFailedError from ZODB.POSException import TransactionFailedError
import doctest import doctest
from BTrees.OOBTree import OOBTree
import transaction import transaction
import unittest import unittest
import ZODB import ZODB
...@@ -27,6 +28,7 @@ import ZODB.tests.util ...@@ -27,6 +28,7 @@ import ZODB.tests.util
class P(Persistent): class P(Persistent):
pass pass
class ZODBTests(ZODB.tests.util.TestCase): class ZODBTests(ZODB.tests.util.TestCase):
def setUp(self): def setUp(self):
...@@ -327,6 +329,28 @@ class ZODBTests(ZODB.tests.util.TestCase): ...@@ -327,6 +329,28 @@ class ZODBTests(ZODB.tests.util.TestCase):
cn.close() 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 = P()
root['added_before_savepoint'] = added_before_savepoint
sp = transaction.savepoint()
added_before_savepoint.btree = new_btree = OOBTree()
cn.add(new_btree)
new_btree['change_to_trigger_read_current'] = P()
sp.rollback()
transaction.commit()
self.assertTrue('added_before_savepoint' in root)
finally:
transaction.abort()
cn.close()
def checkFailingSavepointSticks(self): def checkFailingSavepointSticks(self):
cn = self._db.open() cn = self._db.open()
rt = cn.root() 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