Merge lp:~cjwatson/storm/transaction-2.4.0 into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 489
Proposed branch: lp:~cjwatson/storm/transaction-2.4.0
Merge into: lp:storm
Diff against target: 44 lines (+15/-1)
2 files modified
NEWS (+1/-0)
tests/zope/zstorm.py (+14/-1)
To merge this branch: bzr merge lp:~cjwatson/storm/transaction-2.4.0
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Adam Collard (community) Approve
Review via email: mp+368072@code.launchpad.net

Commit message

Cope with ThreadTransactionManager changes in transaction 2.4.0.

Description of the change

transaction 2.4.0 changed ThreadTransactionManager to wrap TransactionManager rather than inheriting from it, which broke tests because the wrapper doesn't have a "free" method. Apply a somewhat ugly workaround.

I've tested this with both transaction 2.3.0 and 2.4.0 (with the aid of an as-yet-unpushed branch to add tox testing support).

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) :
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Adam Collard (adam-collard) wrote :

+1

review: Approve
Revision history for this message
Simon Poirier (simpoir) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2016-03-01 13:09:28 +0000
3+++ NEWS 2019-05-29 15:17:50 +0000
4@@ -13,6 +13,7 @@
5
6 - Fixed SQLObject tests to work with SQLObject 2.x by using Unicode strings for
7 LIKE operations.
8+- Cope with ThreadTransactionManager changes in transaction 2.4.0.
9
10 API changes
11 -----------
12
13=== modified file 'tests/zope/zstorm.py'
14--- tests/zope/zstorm.py 2012-03-06 10:28:06 +0000
15+++ tests/zope/zstorm.py 2019-05-29 15:17:50 +0000
16@@ -27,6 +27,7 @@
17
18 if has_transaction:
19 import transaction
20+ from transaction import ThreadTransactionManager
21 from storm.zope.interfaces import IZStorm, ZStormError
22 from storm.zope.zstorm import ZStorm, StoreDataManager
23
24@@ -51,7 +52,19 @@
25 self.zstorm._reset()
26 # Free the transaction to avoid having errors that cross
27 # test cases.
28- transaction.manager.free(transaction.get())
29+ # XXX cjwatson 2019-05-29: transaction 2.4.0 changed
30+ # ThreadTransactionManager to wrap TransactionManager rather than
31+ # inheriting from it. For now, cope with either. Simplify this
32+ # once transaction 2.4.0 is old enough that we can reasonably just
33+ # test-depend on it.
34+ manager = transaction.manager
35+ if isinstance(manager, ThreadTransactionManager):
36+ try:
37+ manager.free
38+ except AttributeError:
39+ # transaction >= 2.4.0
40+ manager = manager.manager
41+ manager.free(transaction.get())
42
43 def test_create(self):
44 store = self.zstorm.create(None, "sqlite:")

Subscribers

People subscribed via source and target branches

to status/vote changes: