Commit a08c4728 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #141 from zopefoundation/issue-138

TransactionUndoStorage tests close the conn and db
parents a97ca02f d4d74383
...@@ -3,7 +3,7 @@ sudo: false ...@@ -3,7 +3,7 @@ sudo: false
matrix: matrix:
include: include:
- os: linux - os: linux
python: pypy python: pypy-5.4.1
- os: linux - os: linux
python: pypy3 python: pypy3
env: BUILOUT_OPTIONS=sphinx:eggs= env: BUILOUT_OPTIONS=sphinx:eggs=
......
...@@ -407,6 +407,7 @@ class TransactionalUndoStorage: ...@@ -407,6 +407,7 @@ class TransactionalUndoStorage:
eq = self.assertEqual eq = self.assertEqual
db = DB(self._storage) db = DB(self._storage)
conn = db.open() conn = db.open()
try:
root = conn.root() root = conn.root()
o1 = C() o1 = C()
...@@ -458,10 +459,14 @@ class TransactionalUndoStorage: ...@@ -458,10 +459,14 @@ class TransactionalUndoStorage:
eq(o1.obj, o2) eq(o1.obj, o2)
eq(o1.obj.obj, o3) eq(o1.obj.obj, o3)
self._iterate() self._iterate()
finally:
conn.close()
db.close()
def checkPackAfterUndoDeletion(self): def checkPackAfterUndoDeletion(self):
db = DB(self._storage) db = DB(self._storage)
cn = db.open() cn = db.open()
try:
root = cn.root() root = cn.root()
pack_times = [] pack_times = []
...@@ -512,10 +517,15 @@ class TransactionalUndoStorage: ...@@ -512,10 +517,15 @@ class TransactionalUndoStorage:
self.assertEqual(obj.value, i) self.assertEqual(obj.value, i)
root.items() root.items()
self._inter_pack_pause() self._inter_pack_pause()
finally:
cn.close()
db.close()
def checkPackAfterUndoManyTimes(self): def checkPackAfterUndoManyTimes(self):
db = DB(self._storage) db = DB(self._storage)
cn = db.open() cn = db.open()
try:
rt = cn.root() rt = cn.root()
rt["test"] = MinPO(1) rt["test"] = MinPO(1)
...@@ -555,6 +565,9 @@ class TransactionalUndoStorage: ...@@ -555,6 +565,9 @@ class TransactionalUndoStorage:
self.assertEqual(rt["test"].value, 3) self.assertEqual(rt["test"].value, 3)
self.assertEqual(rt["test2"].value, 2) self.assertEqual(rt["test2"].value, 2)
self._inter_pack_pause() self._inter_pack_pause()
finally:
cn.close()
db.close()
def _inter_pack_pause(self): def _inter_pack_pause(self):
# DirectoryStorage needs a pause between packs, # DirectoryStorage needs a pause between packs,
...@@ -654,6 +667,7 @@ class TransactionalUndoStorage: ...@@ -654,6 +667,7 @@ class TransactionalUndoStorage:
t.setUser(u'u3',path=u'p3') t.setUser(u'u3',path=u'p3')
db = DB(self._storage) db = DB(self._storage)
conn = db.open() conn = db.open()
try:
root = conn.root() root = conn.root()
o1 = C() o1 = C()
root['obj'] = o1 root['obj'] = o1
...@@ -665,6 +679,9 @@ class TransactionalUndoStorage: ...@@ -665,6 +679,9 @@ class TransactionalUndoStorage:
self.assertEqual(d['description'], b't1') self.assertEqual(d['description'], b't1')
self.assertEqual(d['k2'], 'this is transaction metadata') self.assertEqual(d['k2'], 'this is transaction metadata')
self.assertEqual(d['user_name'], b'p3 u3') self.assertEqual(d['user_name'], b'p3 u3')
finally:
conn.close()
db.close()
# A common test body for index tests on undoInfo and undoLog. Before # A common test body for index tests on undoInfo and undoLog. Before
# ZODB 3.4, they always returned a wrong number of results (one too # ZODB 3.4, they always returned a wrong number of results (one too
...@@ -729,8 +746,8 @@ class TransactionalUndoStorage: ...@@ -729,8 +746,8 @@ class TransactionalUndoStorage:
def checkUndoMultipleConflictResolution(self, reverse=False): def checkUndoMultipleConflictResolution(self, reverse=False):
from .ConflictResolution import PCounter from .ConflictResolution import PCounter
db = DB(self._storage) db = DB(self._storage)
cn = db.open() cn = db.open()
try:
cn.root.x = PCounter() cn.root.x = PCounter()
transaction.commit() transaction.commit()
...@@ -748,7 +765,9 @@ class TransactionalUndoStorage: ...@@ -748,7 +765,9 @@ class TransactionalUndoStorage:
transaction.commit() transaction.commit()
self.assertEqual(cn.root.x._value, 2) self.assertEqual(cn.root.x._value, 2)
finally:
cn.close() cn.close()
db.close()
def checkUndoMultipleConflictResolutionReversed(self): def checkUndoMultipleConflictResolutionReversed(self):
self.checkUndoMultipleConflictResolution(True) self.checkUndoMultipleConflictResolution(True)
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