Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
8e97bd7d
Commit
8e97bd7d
authored
Dec 12, 2019
by
Jason Madden
Committed by
GitHub
Dec 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #289 from zopefoundation/transaction30
Fix tests with transaction 3.0.
parents
0b3db5ae
0adcc687
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
245 deletions
+6
-245
CHANGES.rst
CHANGES.rst
+2
-0
src/ZODB/tests/testZODB.py
src/ZODB/tests/testZODB.py
+4
-3
src/ZODB/tests/test_datamanageradapter.py
src/ZODB/tests/test_datamanageradapter.py
+0
-242
No files found.
CHANGES.rst
View file @
8e97bd7d
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
storage. Previously, this produced confusing DEBUG logging. See
storage. Previously, this produced confusing DEBUG logging. See
`issue 282 <https://github.com/zopefoundation/ZODB/issues/282>`_.
`issue 282 <https://github.com/zopefoundation/ZODB/issues/282>`_.
- Fix tests with transaction 3.0.
5.5.1 (2018-10-25)
5.5.1 (2018-10-25)
==================
==================
...
...
src/ZODB/tests/testZODB.py
View file @
8e97bd7d
...
@@ -290,8 +290,9 @@ class ZODBTests(ZODB.tests.util.TestCase):
...
@@ -290,8 +290,9 @@ class ZODBTests(ZODB.tests.util.TestCase):
rt
[
'a'
]
=
1
rt
[
'a'
]
=
1
# Arrange for commit to fail during tpc_vote.
# Arrange for commit to fail during tpc_vote.
poisoned
=
PoisonedObject
(
PoisonedJar
(
break_tpc_vote
=
True
))
poisoned_jar
=
PoisonedJar
(
break_tpc_vote
=
True
)
transaction
.
get
().
register
(
poisoned
)
poisoned
=
PoisonedObject
(
poisoned_jar
)
transaction
.
get
().
join
(
poisoned_jar
)
self
.
assertRaises
(
PoisonedError
,
transaction
.
get
().
commit
)
self
.
assertRaises
(
PoisonedError
,
transaction
.
get
().
commit
)
# Trying to commit again fails too.
# Trying to commit again fails too.
...
@@ -314,7 +315,7 @@ class ZODBTests(ZODB.tests.util.TestCase):
...
@@ -314,7 +315,7 @@ class ZODBTests(ZODB.tests.util.TestCase):
# Cleaning up via begin() should also work.
# Cleaning up via begin() should also work.
rt
[
'a'
]
=
2
rt
[
'a'
]
=
2
transaction
.
get
().
register
(
poisoned
)
transaction
.
get
().
join
(
poisoned_jar
)
self
.
assertRaises
(
PoisonedError
,
transaction
.
commit
)
self
.
assertRaises
(
PoisonedError
,
transaction
.
commit
)
self
.
assertRaises
(
TransactionFailedError
,
transaction
.
commit
)
self
.
assertRaises
(
TransactionFailedError
,
transaction
.
commit
)
# The change to rt['a'] is lost.
# The change to rt['a'] is lost.
...
...
src/ZODB/tests/test_datamanageradapter.py
deleted
100644 → 0
View file @
0b3db5ae
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
unittest
from
doctest
import
DocTestSuite
from
transaction._transaction
import
DataManagerAdapter
from
ZODB.tests.sampledm
import
DataManager
def
test_normal_commit
():
"""
So, we have a data manager:
>>> dm = DataManager()
and we do some work that modifies uncommited state:
>>> dm.inc()
>>> dm.state, dm.delta
(0, 1)
Now we'll commit the changes. When the data manager joins a transaction,
the transaction will create an adapter.
>>> dma = DataManagerAdapter(dm)
and register it as a modified object. At commit time, the
transaction will get the "jar" like this:
>>> jar = getattr(dma, '_p_jar', dma)
and, of course, the jar and the adapter will be the same:
>>> jar is dma
True
The transaction will call tpc_begin:
>>> t1 = '1'
>>> jar.tpc_begin(t1)
Then the transaction will call commit on the jar:
>>> jar.commit(t1)
This doesn't actually do anything. :)
>>> dm.state, dm.delta
(0, 1)
The transaction will then call tpc_vote:
>>> jar.tpc_vote(t1)
This prepares the data manager:
>>> dm.state, dm.delta
(1, 1)
>>> dm.prepared
True
Finally, tpc_finish is called:
>>> jar.tpc_finish(t1)
and the data manager finishes the two-phase commit:
>>> dm.state, dm.delta
(1, 0)
>>> dm.prepared
False
"""
def
test_abort
():
"""
So, we have a data manager:
>>> dm = DataManager()
and we do some work that modifies uncommited state:
>>> dm.inc()
>>> dm.state, dm.delta
(0, 1)
When the data manager joins a transaction,
the transaction will create an adapter.
>>> dma = DataManagerAdapter(dm)
and register it as a modified object.
Now we'll abort the transaction. The transaction will get the
"jar" like this:
>>> jar = getattr(dma, '_p_jar', dma)
and, of course, the jar and the adapter will be the same:
>>> jar is dma
True
Then the transaction will call abort on the jar:
>>> t1 = '1'
>>> jar.abort(t1)
Which aborts the changes in the data manager:
>>> dm.state, dm.delta
(0, 0)
"""
def
test_tpc_abort_phase1
():
"""
So, we have a data manager:
>>> dm = DataManager()
and we do some work that modifies uncommited state:
>>> dm.inc()
>>> dm.state, dm.delta
(0, 1)
Now we'll commit the changes. When the data manager joins a transaction,
the transaction will create an adapter.
>>> dma = DataManagerAdapter(dm)
and register it as a modified object. At commit time, the
transaction will get the "jar" like this:
>>> jar = getattr(dma, '_p_jar', dma)
and, of course, the jar and the adapter will be the same:
>>> jar is dma
True
The transaction will call tpc_begin:
>>> t1 = '1'
>>> jar.tpc_begin(t1)
Then the transaction will call commit on the jar:
>>> jar.commit(t1)
This doesn't actually do anything. :)
>>> dm.state, dm.delta
(0, 1)
At this point, the transaction decides to abort. It calls tpc_abort:
>>> jar.tpc_abort(t1)
Which causes the state of the data manager to be restored:
>>> dm.state, dm.delta
(0, 0)
"""
def
test_tpc_abort_phase2
():
"""
So, we have a data manager:
>>> dm = DataManager()
and we do some work that modifies uncommited state:
>>> dm.inc()
>>> dm.state, dm.delta
(0, 1)
Now we'll commit the changes. When the data manager joins a transaction,
the transaction will create an adapter.
>>> dma = DataManagerAdapter(dm)
and register it as a modified object. At commit time, the
transaction will get the "jar" like this:
>>> jar = getattr(dma, '_p_jar', dma)
and, of course, the jar and the adapter will be the same:
>>> jar is dma
True
The transaction will call tpc_begin:
>>> t1 = '1'
>>> jar.tpc_begin(t1)
Then the transaction will call commit on the jar:
>>> jar.commit(t1)
This doesn't actually do anything. :)
>>> dm.state, dm.delta
(0, 1)
The transaction calls vote:
>>> jar.tpc_vote(t1)
This prepares the data manager:
>>> dm.state, dm.delta
(1, 1)
>>> dm.prepared
True
At this point, the transaction decides to abort. It calls tpc_abort:
>>> jar.tpc_abort(t1)
Which causes the state of the data manager to be restored:
>>> dm.state, dm.delta
(0, 0)
>>> dm.prepared
False
"""
def
test_suite
():
return
DocTestSuite
()
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment