Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
bb904cd2
Commit
bb904cd2
authored
Jan 27, 2003
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BerkeleyTestBase: Backport of refactoring.
parent
7de420dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
lib/python/BDBStorage/tests/BerkeleyTestBase.py
lib/python/BDBStorage/tests/BerkeleyTestBase.py
+29
-19
No files found.
lib/python/BDBStorage/tests/BerkeleyTestBase.py
View file @
bb904cd2
...
...
@@ -17,6 +17,7 @@
import
os
import
errno
import
shutil
from
BDBStorage.BerkeleyBase
import
BerkeleyConfig
from
ZODB.tests.StorageTestBase
import
StorageTestBase
...
...
@@ -26,40 +27,49 @@ DBHOME = 'test-db'
class
BerkeleyTestBase
(
StorageTestBase
):
def
_zap_dbhome
(
self
,
dir
):
# If the tests exited with any uncommitted objects, they'll blow up
# subsequent tests because the next transaction commit will try to
# commit those object. But they're tied to closed databases, so
# that's broken. Aborting the transaction now saves us the headache.
try
:
for
file
in
os
.
listdir
(
dir
):
os
.
unlink
(
os
.
path
.
join
(
dir
,
file
))
os
.
removedirs
(
dir
)
except
OSError
,
e
:
if
e
.
errno
<>
errno
.
ENOENT
:
raise
def
_mk_dbhome
(
self
,
dir
):
def
_config
(
self
):
# Checkpointing just slows the tests down because we have to wait for
# the thread to properly shutdown. This can take up to 10 seconds, so
# for the purposes of the test suite we shut off this thread.
config
=
BerkeleyConfig
()
config
.
interval
=
0
return
config
def
_envdir
(
self
):
return
DBHOME
def
open
(
self
):
self
.
_storage
=
self
.
ConcreteStorage
(
self
.
_envdir
(),
config
=
self
.
_config
())
def
_zap_dbhome
(
self
,
dir
=
None
):
if
dir
is
None
:
dir
=
self
.
_envdir
()
# XXX Pre-Python 2.3 doesn't ignore errors if the first arg doesn't
# exist, even if the second is True.
try
:
shutil
.
rmtree
(
dir
,
True
)
except
OSError
,
e
:
if
e
.
errno
<>
errno
.
ENOENT
:
raise
def
_mk_dbhome
(
self
,
dir
=
None
):
if
dir
is
None
:
dir
=
self
.
_get_envdir
()
os
.
mkdir
(
dir
)
try
:
return
self
.
ConcreteStorage
(
dir
,
config
=
config
)
return
self
.
ConcreteStorage
(
dir
,
config
=
self
.
_config
()
)
except
:
self
.
_zap_dbhome
(
dir
)
self
.
_zap_dbhome
()
raise
def
setUp
(
self
):
StorageTestBase
.
setUp
(
self
)
self
.
_zap_dbhome
(
DBHOME
)
self
.
_storage
=
self
.
_mk_dbhome
(
DBHOME
)
self
.
_zap_dbhome
()
self
.
open
(
)
def
tearDown
(
self
):
StorageTestBase
.
tearDown
(
self
)
self
.
_zap_dbhome
(
DBHOME
)
self
.
_zap_dbhome
()
...
...
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