summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/bsddb/test')
-rw-r--r--Lib/bsddb/test/test_associate.py16
-rw-r--r--Lib/bsddb/test/test_basics.py11
-rw-r--r--Lib/bsddb/test/test_compare.py5
-rw-r--r--Lib/bsddb/test/test_cursor_pget_bug.py5
-rw-r--r--Lib/bsddb/test/test_dbobj.py9
-rw-r--r--Lib/bsddb/test/test_dbshelve.py8
-rw-r--r--Lib/bsddb/test/test_dbtables.py12
-rw-r--r--Lib/bsddb/test/test_env_close.py12
-rw-r--r--Lib/bsddb/test/test_join.py8
-rw-r--r--Lib/bsddb/test/test_lock.py6
-rw-r--r--Lib/bsddb/test/test_misc.py13
-rw-r--r--Lib/bsddb/test/test_pickle.py6
-rw-r--r--Lib/bsddb/test/test_recno.py17
-rw-r--r--Lib/bsddb/test/test_sequence.py6
-rw-r--r--Lib/bsddb/test/test_thread.py9
15 files changed, 86 insertions, 57 deletions
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
index ab7b600..1a32460 100644
--- a/Lib/bsddb/test/test_associate.py
+++ b/Lib/bsddb/test/test_associate.py
@@ -92,15 +92,23 @@ musicdata = {
class AssociateErrorTestCase(unittest.TestCase):
def setUp(self):
self.filename = self.__class__.__name__ + '.db'
- self.homeDir = tempfile.mkdtemp()
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
+ try:
+ os.mkdir(homeDir)
+ except os.error:
+ import glob
+ files = glob.glob(os.path.join(self.homeDir, '*'))
+ for file in files:
+ os.remove(file)
self.env = db.DBEnv()
self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
def tearDown(self):
self.env.close()
self.env = None
- shutil.rmtree(self.homeDir)
-
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test00_associateDBError(self):
if verbose:
@@ -141,7 +149,7 @@ class AssociateTestCase(unittest.TestCase):
def setUp(self):
self.filename = self.__class__.__name__ + '.db'
- homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
self.homeDir = homeDir
try:
os.mkdir(homeDir)
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index 8d7f15d..77ef361 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -6,10 +6,10 @@ various DB flags, etc.
import os
import sys
import errno
-import shutil
import string
import tempfile
from pprint import pprint
+from test import test_support
import unittest
import time
@@ -54,7 +54,10 @@ class BasicTestCase(unittest.TestCase):
def setUp(self):
if self.useEnv:
- self.homeDir = tempfile.mkdtemp()
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
+ test_support.rmtree(homeDir)
+ os.mkdir(homeDir)
try:
self.env = db.DBEnv()
self.env.set_lg_max(1024*1024)
@@ -68,7 +71,7 @@ class BasicTestCase(unittest.TestCase):
tempfile.tempdir = old_tempfile_tempdir
# Yes, a bare except is intended, since we're re-raising the exc.
except:
- shutil.rmtree(self.homeDir)
+ test_support.rmtree(homeDir)
raise
else:
self.env = None
@@ -92,8 +95,8 @@ class BasicTestCase(unittest.TestCase):
def tearDown(self):
self.d.close()
if self.env is not None:
+ test_support.rmtree(self.homeDir)
self.env.close()
- shutil.rmtree(self.homeDir)
## Make a new DBEnv to remove the env files from the home dir.
## (It can't be done while the env is open, nor after it has been
## closed, so we make a new one to do it.)
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
index 49aa7ca..3e9ecce 100644
--- a/Lib/bsddb/test/test_compare.py
+++ b/Lib/bsddb/test/test_compare.py
@@ -66,7 +66,7 @@ class AbstractBtreeKeyCompareTestCase (unittest.TestCase):
def setUp (self):
self.filename = self.__class__.__name__ + '.db'
- homeDir = os.path.join (tempfile.gettempdir(), 'db_home')
+ homeDir = os.path.join (tempfile.gettempdir(), 'db_home%d'%os.getpid())
self.homeDir = homeDir
try:
os.mkdir (homeDir)
@@ -84,7 +84,8 @@ class AbstractBtreeKeyCompareTestCase (unittest.TestCase):
if self.env is not None:
self.env.close ()
self.env = None
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def addDataToDB (self, data):
i = 0
diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py
index 32dd8a5..6682180 100644
--- a/Lib/bsddb/test/test_cursor_pget_bug.py
+++ b/Lib/bsddb/test/test_cursor_pget_bug.py
@@ -14,7 +14,7 @@ class pget_bugTestCase(unittest.TestCase):
db_name = 'test-cursor_pget.db'
def setUp(self):
- self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
+ self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
try:
os.mkdir(self.homeDir)
except os.error:
@@ -39,7 +39,8 @@ class pget_bugTestCase(unittest.TestCase):
del self.secondary_db
del self.primary_db
del self.env
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test_pget(self):
cursor = self.secondary_db.cursor()
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
index 22d46bc..2d0f916 100644
--- a/Lib/bsddb/test/test_dbobj.py
+++ b/Lib/bsddb/test/test_dbobj.py
@@ -2,7 +2,6 @@
import shutil
import sys, os
import unittest
-import glob
import tempfile
try:
@@ -20,14 +19,18 @@ class dbobjTestCase(unittest.TestCase):
db_name = 'test-dbobj.db'
def setUp(self):
- self.homeDir = tempfile.mkdtemp()
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
+ try: os.mkdir(homeDir)
+ except os.error: pass
def tearDown(self):
if hasattr(self, 'db'):
del self.db
if hasattr(self, 'env'):
del self.env
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test01_both(self):
class TestDBEnv(dbobj.DBEnv): pass
diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py
index 64cf59a..c66c7c1 100644
--- a/Lib/bsddb/test/test_dbshelve.py
+++ b/Lib/bsddb/test/test_dbshelve.py
@@ -262,6 +262,10 @@ class BasicEnvShelveTestCase(DBShelveTestCase):
self.do_open()
def do_open(self):
+ self.homeDir = homeDir = os.path.join(
+ tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ try: os.mkdir(homeDir)
+ except os.error: pass
self.env = db.DBEnv()
self.env.open(self.homeDir, self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
@@ -275,9 +279,9 @@ class BasicEnvShelveTestCase(DBShelveTestCase):
def tearDown(self):
+ from test import test_support
+ test_support.rmtree(self.homeDir)
self.do_close()
- shutil.rmtree(self.homeDir)
-
class EnvBTreeShelveTestCase(BasicEnvShelveTestCase):
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index 149f3bd..6c168bc 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -20,7 +20,6 @@
#
# $Id$
-import shutil
import sys, os, re
import pickle
import tempfile
@@ -43,13 +42,18 @@ class TableDBTestCase(unittest.TestCase):
db_name = 'test-table.db'
def setUp(self):
- self.homeDir = tempfile.mkdtemp()
+ homeDir = tempfile.mkdtemp()
+ self.testHomeDir = homeDir
+ try: os.mkdir(homeDir)
+ except os.error: pass
+
self.tdb = dbtables.bsdTableDB(
- filename='tabletest.db', dbhome=self.homeDir, create=1)
+ filename='tabletest.db', dbhome=homeDir, create=1)
def tearDown(self):
self.tdb.close()
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.testHomeDir)
def test01(self):
tabname = "test01"
diff --git a/Lib/bsddb/test/test_env_close.py b/Lib/bsddb/test/test_env_close.py
index 2ef5867..fa3adad 100644
--- a/Lib/bsddb/test/test_env_close.py
+++ b/Lib/bsddb/test/test_env_close.py
@@ -6,7 +6,6 @@ import os
import shutil
import sys
import tempfile
-import glob
import unittest
try:
@@ -34,15 +33,16 @@ else:
class DBEnvClosedEarlyCrash(unittest.TestCase):
def setUp(self):
- self.homeDir = tempfile.mkdtemp()
- old_tempfile_tempdir = tempfile.tempdir
+ self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ try: os.mkdir(self.homeDir)
+ except os.error: pass
tempfile.tempdir = self.homeDir
self.filename = os.path.split(tempfile.mktemp())[1]
- tempfile.tempdir = old_tempfile_tempdir
+ tempfile.tempdir = None
def tearDown(self):
- shutil.rmtree(self.homeDir)
-
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test01_close_dbenv_before_db(self):
dbenv = db.DBEnv()
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
index 5657bd7..07e7e01 100644
--- a/Lib/bsddb/test/test_join.py
+++ b/Lib/bsddb/test/test_join.py
@@ -48,13 +48,17 @@ class JoinTestCase(unittest.TestCase):
def setUp(self):
self.filename = self.__class__.__name__ + '.db'
- self.homeDir = tempfile.mkdtemp()
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
+ try: os.mkdir(homeDir)
+ except os.error: pass
self.env = db.DBEnv()
self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK )
def tearDown(self):
self.env.close()
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test01_join(self):
if verbose:
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py
index bbd88bd..ca521de 100644
--- a/Lib/bsddb/test/test_lock.py
+++ b/Lib/bsddb/test/test_lock.py
@@ -2,9 +2,6 @@
TestCases for testing the locking sub-system.
"""
-import os
-from pprint import pprint
-import shutil
import sys
import tempfile
import time
@@ -40,7 +37,8 @@ class LockingTestCase(unittest.TestCase):
def tearDown(self):
self.env.close()
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test01_simple(self):
diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py
index b7a6710..5b9ab0a 100644
--- a/Lib/bsddb/test/test_misc.py
+++ b/Lib/bsddb/test/test_misc.py
@@ -19,14 +19,17 @@ except ImportError:
class MiscTestCase(unittest.TestCase):
def setUp(self):
self.filename = self.__class__.__name__ + '.db'
- self.homeDir = tempfile.mkdtemp()
-
- def tearDown(self):
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
try:
- os.remove(self.filename)
+ os.mkdir(homeDir)
except OSError:
pass
- shutil.rmtree(self.homeDir)
+
+ def tearDown(self):
+ from test import test_support
+ test_support.unlink(self.filename)
+ test_support.rmtree(self.homeDir)
def test01_badpointer(self):
dbs = dbshelve.open(self.filename)
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py
index 9b413c4..01a5c45 100644
--- a/Lib/bsddb/test/test_pickle.py
+++ b/Lib/bsddb/test/test_pickle.py
@@ -5,7 +5,6 @@ import pickle
import tempfile
import unittest
import tempfile
-import glob
try:
# For Pythons w/distutils pybsddb
@@ -22,7 +21,7 @@ class pickleTestCase(unittest.TestCase):
db_name = 'test-dbobj.db'
def setUp(self):
- homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
self.homeDir = homeDir
try: os.mkdir(homeDir)
except os.error: pass
@@ -32,7 +31,8 @@ class pickleTestCase(unittest.TestCase):
del self.db
if hasattr(self, 'env'):
del self.env
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def _base_test_pickle_DBError(self, pickle):
self.env = db.DBEnv()
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index e001b63..dc15ad1 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -26,14 +26,13 @@ letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
class SimpleRecnoTestCase(unittest.TestCase):
def setUp(self):
self.filename = tempfile.mktemp()
- self.homeDir = tempfile.mkdtemp()
+ self.homeDir = None
def tearDown(self):
- try:
- os.remove(self.filename)
- except OSError as e:
- if e.errno != errno.EEXIST: raise
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.unlink(self.filename)
+ if self.homeDir:
+ test_support.rmtree(self.homeDir)
def test01_basic(self):
d = db.DB()
@@ -206,7 +205,11 @@ class SimpleRecnoTestCase(unittest.TestCase):
just a line in the file, but you can set a different record delimiter
if needed.
"""
- source = os.path.join(self.homeDir, 'test_recno.txt')
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+ self.homeDir = homeDir
+ source = os.path.join(homeDir, 'test_recno.txt')
+ if not os.path.isdir(homeDir):
+ os.mkdir(homeDir)
f = open(source, 'w') # create the file
f.close()
diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py
index e630f1a..fa80e7c 100644
--- a/Lib/bsddb/test/test_sequence.py
+++ b/Lib/bsddb/test/test_sequence.py
@@ -3,7 +3,6 @@ import os
import shutil
import sys
import tempfile
-import glob
try:
# For Pythons w/distutils pybsddb
@@ -17,7 +16,7 @@ from bsddb.test.test_all import verbose
class DBSequenceTest(unittest.TestCase):
def setUp(self):
self.int_32_max = 0x100000000
- self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
+ self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
try:
os.mkdir(self.homeDir)
except os.error:
@@ -42,7 +41,8 @@ class DBSequenceTest(unittest.TestCase):
self.dbenv.close()
del self.dbenv
- shutil.rmtree(self.homeDir)
+ from test import test_support
+ test_support.rmtree(self.homeDir)
def test_get(self):
self.seq = db.DBSequence(self.d, flags=0)
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
index 20a643b..7397a50 100644
--- a/Lib/bsddb/test/test_thread.py
+++ b/Lib/bsddb/test/test_thread.py
@@ -5,7 +5,6 @@ import os
import sys
import time
import errno
-import shutil
import tempfile
from pprint import pprint
from random import random
@@ -47,7 +46,7 @@ class BaseThreadedTestCase(unittest.TestCase):
if verbose:
dbutils._deadlock_VerboseFile = sys.stdout
- homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
+ homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
self.homeDir = homeDir
try:
os.mkdir(homeDir)
@@ -64,12 +63,10 @@ class BaseThreadedTestCase(unittest.TestCase):
self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE)
def tearDown(self):
+ from test import test_support
+ test_support.rmtree(self.homeDir)
self.d.close()
self.env.close()
- try:
- shutil.rmtree(self.homeDir)
- except OSError as e:
- if e.errno != errno.EEXIST: raise
def setEnvOpts(self):
pass