Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
transaction
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
transaction
Commits
5156b59f
Commit
5156b59f
authored
Dec 17, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move utility helpers into shared module.
parent
c729e5f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
37 deletions
+50
-37
docs/hooks.rst
docs/hooks.rst
+6
-6
transaction/tests/common.py
transaction/tests/common.py
+44
-0
transaction/tests/test__transaction.py
transaction/tests/test__transaction.py
+0
-31
No files found.
docs/hooks.rst
View file @
5156b59f
...
...
@@ -104,9 +104,9 @@ commit, we'll add failing resource manager to the transaction.
>>> t.addBeforeCommitHook(hook, '2')
>>> from transaction.tests.
test__transacti
on import DummyFile
>>> from transaction.tests.
test__transacti
on import Monkey
>>> from transaction.tests.
test__transacti
on import assertRaisesEx
>>> from transaction.tests.
comm
on import DummyFile
>>> from transaction.tests.
comm
on import Monkey
>>> from transaction.tests.
comm
on import assertRaisesEx
>>> from transaction import _transaction
>>> buffer = DummyFile()
>>> with Monkey(_transaction, _TB_BUFFER=buffer):
...
...
@@ -270,9 +270,9 @@ commit, we'll add failing resource manager to the transaction.
>>> t.join(FailingDataManager())
>>> t.addAfterCommitHook(hook, '2')
>>> from transaction.tests.
test__transacti
on import DummyFile
>>> from transaction.tests.
test__transacti
on import Monkey
>>> from transaction.tests.
test__transacti
on import assertRaisesEx
>>> from transaction.tests.
comm
on import DummyFile
>>> from transaction.tests.
comm
on import Monkey
>>> from transaction.tests.
comm
on import assertRaisesEx
>>> from transaction import _transaction
>>> buffer = DummyFile()
>>> with Monkey(_transaction, _TB_BUFFER=buffer):
...
...
transaction/tests/common.py
0 → 100644
View file @
5156b59f
##############################################################################
#
# Copyright (c) 2012 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
#
##############################################################################
class
DummyFile
(
object
):
def
__init__
(
self
):
self
.
_lines
=
[]
def
write
(
self
,
text
):
self
.
_lines
.
append
(
text
)
def
writelines
(
self
,
lines
):
self
.
_lines
.
extend
(
lines
)
class
Monkey
(
object
):
# context-manager for replacing module names in the scope of a test.
def
__init__
(
self
,
module
,
**
kw
):
self
.
module
=
module
self
.
to_restore
=
dict
([(
key
,
getattr
(
module
,
key
))
for
key
in
kw
])
for
key
,
value
in
kw
.
items
():
setattr
(
module
,
key
,
value
)
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
for
key
,
value
in
self
.
to_restore
.
items
():
setattr
(
self
.
module
,
key
,
value
)
def
assertRaisesEx
(
e_type
,
checked
,
*
args
,
**
kw
):
try
:
checked
(
*
args
,
**
kw
)
except
e_type
as
e
:
return
e
raise
AssertionError
(
"Didn't raise: %s"
%
e_type
.
__name__
)
transaction/tests/test__transaction.py
View file @
5156b59f
...
...
@@ -39,37 +39,6 @@ TODO
import
unittest
class
DummyFile
(
object
):
def
__init__
(
self
):
self
.
_lines
=
[]
def
write
(
self
,
text
):
self
.
_lines
.
append
(
text
)
def
writelines
(
self
,
lines
):
self
.
_lines
.
extend
(
lines
)
class
Monkey
(
object
):
# context-manager for replacing module names in the scope of a test.
def
__init__
(
self
,
module
,
**
kw
):
self
.
module
=
module
self
.
to_restore
=
dict
([(
key
,
getattr
(
module
,
key
))
for
key
in
kw
])
for
key
,
value
in
kw
.
items
():
setattr
(
module
,
key
,
value
)
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
for
key
,
value
in
self
.
to_restore
.
items
():
setattr
(
self
.
module
,
key
,
value
)
def
assertRaisesEx
(
e_type
,
checked
,
*
args
,
**
kw
):
try
:
checked
(
*
args
,
**
kw
)
except
e_type
as
e
:
return
e
raise
AssertionError
(
"Didn't raise: %s"
%
e_type
.
__name__
)
class
TransactionTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
...
...
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