Skip to content

Commit

Permalink
Updated some tests and test support to use TransactionMetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Nov 17, 2016
1 parent d2b72af commit f0f0035
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/ZODB/FileStorage/tests.py
Expand Up @@ -20,6 +20,7 @@
import ZODB.blob
import ZODB.FileStorage
import ZODB.tests.util
from ZODB.Connection import TransactionMetaData
from zope.testing import renormalizing

checker = renormalizing.RENormalizing([
Expand Down Expand Up @@ -124,7 +125,7 @@ def pack_with_repeated_blob_records():
Now, create a transaction with multiple saves:
>>> trans = tm.begin()
>>> trans = TransactionMetaData()
>>> fs.tpc_begin(trans)
>>> with open('ablob', 'w') as file:
... _ = file.write('some data')
Expand All @@ -151,7 +152,7 @@ def _save_index():
>>> import ZODB.utils
>>> fs = ZODB.FileStorage.FileStorage('data.fs')
>>> t = transaction.begin()
>>> t = TransactionMetaData()
>>> fs.tpc_begin(t)
>>> oid = 0
>>> for i in range(5000):
Expand Down
5 changes: 3 additions & 2 deletions src/ZODB/tests/IExternalGC.test
Expand Up @@ -41,7 +41,8 @@ Now we'll use the new deleteObject API to delete the objects. We can't
go through the database to do this, so we'll have to manage the
transaction ourselves.

>>> txn = transaction.begin()
>>> from ZODB.Connection import TransactionMetaData
>>> txn = TransactionMetaData()
>>> storage.tpc_begin(txn)
>>> storage.deleteObject(oid0, s0, txn)
>>> storage.deleteObject(oid1, s1, txn)
Expand Down Expand Up @@ -116,7 +117,7 @@ isn't current:
>>> conn.root()[0].x = 1
>>> transaction.commit()

>>> txn = transaction.begin()
>>> txn = TransactionMetaData()
>>> storage.tpc_begin(txn)
>>> storage.deleteObject(oid, bad_serial, txn); storage.tpc_vote(txn)
... # doctest: +ELLIPSIS
Expand Down
4 changes: 2 additions & 2 deletions src/ZODB/tests/PackableStorage.py
Expand Up @@ -144,12 +144,12 @@ def _initroot(self):
try:
load_current(self._storage, ZERO)
except KeyError:
from transaction import Transaction
from ZODB.Connection import TransactionMetaData
file = BytesIO()
p = Pickler(file, _protocol)
p.dump((PersistentMapping, None))
p.dump({'_container': {}})
t=Transaction()
t = TransactionMetaData()
t.description = u'initial database creation'
self._storage.tpc_begin(t)
self._storage.store(ZERO, None, file.getvalue(), '', t)
Expand Down
3 changes: 2 additions & 1 deletion src/ZODB/tests/blob_transaction.txt
Expand Up @@ -377,7 +377,8 @@ If a transaction is aborted in the middle of 2-phase commit, any data
stored are discarded.

>>> olddata, oldserial = blob_storage.load(blob._p_oid, '')
>>> t = transaction.get()
>>> from ZODB.Connection import TransactionMetaData
>>> t = TransactionMetaData()
>>> blob_storage.tpc_begin(t)
>>> with open('blobfile', 'wb') as file:
... _ = file.write(b'This data should go away')
Expand Down
3 changes: 2 additions & 1 deletion src/ZODB/tests/util.py
Expand Up @@ -25,6 +25,7 @@
import unittest
import warnings
import ZODB.utils
from ZODB.Connection import TransactionMetaData
import zope.testing.setupstack
from zope.testing import renormalizing

Expand Down Expand Up @@ -161,7 +162,7 @@ def store(storage, oid, value='x', serial=ZODB.utils.z64):
oid = ZODB.utils.p64(oid)
if not isinstance(serial, bytes):
serial = ZODB.utils.p64(serial)
t = transaction.get()
t = TransactionMetaData()
storage.tpc_begin(t)
storage.store(oid, serial, value, '', t)
storage.tpc_vote(t)
Expand Down

0 comments on commit f0f0035

Please sign in to comment.