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