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
Joshua
zodb
Commits
bd415c7a
Commit
bd415c7a
authored
Jul 10, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a number of helpers.
parent
5c263660
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
2 deletions
+41
-2
src/ZODB/tests/util.py
src/ZODB/tests/util.py
+41
-2
No files found.
src/ZODB/tests/util.py
View file @
bd415c7a
...
...
@@ -12,10 +12,10 @@
#
##############################################################################
"""Conventience function for creating test databases
$Id$
"""
from
__future__
import
with_statement
from
ZODB.MappingStorage
import
DB
import
atexit
...
...
@@ -24,8 +24,12 @@ import tempfile
import
time
import
unittest
import
persistent
import
sys
import
time
import
transaction
import
warnings
import
zope.testing.setupstack
import
ZODB.utils
def
setUp
(
test
,
name
=
'test'
):
transaction
.
abort
()
...
...
@@ -99,3 +103,38 @@ class AAAA_Test_Runner_Hack(unittest.TestCase):
def
testNothing
(
self
):
pass
def
assert_warning
(
category
,
func
,
warning_text
=
''
):
if
sys
.
version_info
<
(
2
,
6
):
return
func
()
# Can't use catch_warnings :(
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'default'
)
result
=
func
()
for
warning
in
w
:
if
((
warning
.
category
is
category
)
and
(
warning_text
in
str
(
warning
.
message
))):
return
result
raise
AssertionError
(
w
)
def
assert_deprecated
(
func
,
warning_text
=
''
):
return
assert_warning
(
DeprecationWarning
,
func
,
warning_text
)
def
wait
(
func
=
None
,
timeout
=
30
):
if
func
is
None
:
return
lambda
f
:
wait
(
f
,
timeout
)
for
i
in
xrange
(
int
(
timeout
*
100
)):
if
func
():
return
time
.
sleep
(.
01
)
raise
AssertionError
def
store
(
storage
,
oid
,
value
=
'x'
,
serial
=
ZODB
.
utils
.
z64
):
if
not
isinstance
(
oid
,
str
):
oid
=
ZODB
.
utils
.
p64
(
oid
)
if
not
isinstance
(
serial
,
str
):
serial
=
ZODB
.
utils
.
p64
(
serial
)
t
=
transaction
.
get
()
storage
.
tpc_begin
(
t
)
storage
.
store
(
oid
,
serial
,
value
,
''
,
t
)
storage
.
tpc_vote
(
t
)
storage
.
tpc_finish
(
t
)
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