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
nexedi
ZODB
Commits
fd12a91e
Commit
fd12a91e
authored
Mar 12, 2002
by
Kapil Thangavelu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more extensive unittesting for the transaction framework.
parent
84749093
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
88 deletions
+0
-88
src/ZODB/tests/testTransaction.py
src/ZODB/tests/testTransaction.py
+0
-88
No files found.
src/ZODB/tests/testTransaction.py
deleted
100644 → 0
View file @
84749093
"""High-level tests of the transaction interface"""
import
os
import
tempfile
import
unittest
import
ZODB
from
ZODB.DB
import
DB
from
ZODB.FileStorage
import
FileStorage
from
ZODB.tests.MinPO
import
MinPO
class
TransactionTestBase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
fs_path
=
tempfile
.
mktemp
()
self
.
fs
=
FileStorage
(
self
.
fs_path
)
db
=
DB
(
self
.
fs
)
conn
=
db
.
open
()
self
.
root
=
conn
.
root
()
def
tearDown
(
self
):
self
.
fs
.
close
()
for
ext
in
''
,
'.index'
,
'.lock'
,
'.tmp'
:
path
=
self
.
fs_path
+
ext
if
os
.
path
.
exists
(
path
):
os
.
unlink
(
path
)
class
BasicTests
:
def
checkSingleCommit
(
self
,
subtrans
=
None
):
self
.
root
[
"a"
]
=
MinPO
(
"a"
)
get_transaction
().
commit
(
subtrans
)
assert
self
.
root
[
"a"
].
value
==
"a"
def
checkMultipleCommits
(
self
,
subtrans
=
None
):
a
=
self
.
root
[
"a"
]
=
MinPO
(
"a"
)
get_transaction
().
commit
(
subtrans
)
a
.
extra_attr
=
MinPO
(
"b"
)
get_transaction
().
commit
(
subtrans
)
del
a
assert
self
.
root
[
"a"
].
value
==
"a"
assert
self
.
root
[
"a"
].
extra_attr
==
MinPO
(
"b"
)
def
checkCommitAndAbort
(
self
,
subtrans
=
None
):
a
=
self
.
root
[
"a"
]
=
MinPO
(
"a"
)
get_transaction
().
commit
(
subtrans
)
a
.
extra_attr
=
MinPO
(
"b"
)
get_transaction
().
abort
()
del
a
if
subtrans
:
assert
not
self
.
root
.
has_key
(
"a"
)
else
:
assert
self
.
root
[
"a"
].
value
==
"a"
assert
not
hasattr
(
self
.
root
[
"a"
],
'extra_attr'
)
class
SubtransTests
:
def
wrap_test
(
self
,
klass
,
meth_name
):
obj
=
klass
()
obj
.
root
=
self
.
root
meth
=
getattr
(
obj
,
meth_name
)
meth
(
1
)
get_transaction
().
commit
()
checkSubSingleCommit
=
lambda
self
:
\
self
.
wrap_test
(
BasicTests
,
"checkSingleCommit"
)
checkSubMultipleCommits
=
lambda
self
:
\
self
.
wrap_test
(
BasicTests
,
"checkMultipleCommits"
)
checkSubCommitAndAbort
=
lambda
self
:
\
self
.
wrap_test
(
BasicTests
,
"checkCommitAndAbort"
)
class
AllTests
(
TransactionTestBase
,
BasicTests
,
SubtransTests
):
pass
def
test_suite
():
return
unittest
.
makeSuite
(
AllTests
,
'check'
)
def
main
():
tests
=
test_suite
()
runner
=
unittest
.
TextTestRunner
()
runner
.
run
(
tests
)
if
__name__
==
"__main__"
:
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