diff options
Diffstat (limited to 'Lib/bsddb/test')
-rw-r--r-- | Lib/bsddb/test/test_associate.py | 10 | ||||
-rw-r--r-- | Lib/bsddb/test/test_compare.py | 8 | ||||
-rw-r--r-- | Lib/bsddb/test/test_cursor_pget_bug.py | 7 | ||||
-rw-r--r-- | Lib/bsddb/test/test_pickle.py | 6 | ||||
-rw-r--r-- | Lib/bsddb/test/test_sequence.py | 7 | ||||
-rw-r--r-- | Lib/bsddb/test/test_thread.py | 12 |
6 files changed, 42 insertions, 8 deletions
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py index 7d0dceb..ab7b600 100644 --- a/Lib/bsddb/test/test_associate.py +++ b/Lib/bsddb/test/test_associate.py @@ -141,7 +141,15 @@ class AssociateTestCase(unittest.TestCase): def setUp(self): self.filename = self.__class__.__name__ + '.db' - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + 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 | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags) diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py index f823a75..eefc7c2 100644 --- a/Lib/bsddb/test/test_compare.py +++ b/Lib/bsddb/test/test_compare.py @@ -6,6 +6,7 @@ import shutil import sys, os, re from io import StringIO import tempfile +import test_all import unittest try: @@ -55,7 +56,12 @@ class AbstractBtreeKeyCompareTestCase (unittest.TestCase): def setUp (self): self.filename = self.__class__.__name__ + '.db' - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join (tempfile.gettempdir(), 'db_home') + self.homeDir = homeDir + try: + os.mkdir (homeDir) + except os.error: + pass env = db.DBEnv () env.open (self.homeDir, diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py index 2af12bf..32dd8a5 100644 --- a/Lib/bsddb/test/test_cursor_pget_bug.py +++ b/Lib/bsddb/test/test_cursor_pget_bug.py @@ -1,4 +1,5 @@ import unittest +import tempfile import sys, os, glob import shutil import tempfile @@ -13,7 +14,11 @@ class pget_bugTestCase(unittest.TestCase): db_name = 'test-cursor_pget.db' def setUp(self): - self.homeDir = tempfile.mkdtemp() + self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + try: + os.mkdir(self.homeDir) + except os.error: + pass self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) self.primary_db = db.DB(self.env) diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py index 3bedab7..9b413c4 100644 --- a/Lib/bsddb/test/test_pickle.py +++ b/Lib/bsddb/test/test_pickle.py @@ -4,6 +4,7 @@ import sys, os import pickle import tempfile import unittest +import tempfile import glob try: @@ -21,7 +22,10 @@ class pickleTestCase(unittest.TestCase): db_name = 'test-dbobj.db' def setUp(self): - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + self.homeDir = homeDir + try: os.mkdir(homeDir) + except os.error: pass def tearDown(self): if hasattr(self, 'db'): diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py index 25a354c..f998df7 100644 --- a/Lib/bsddb/test/test_sequence.py +++ b/Lib/bsddb/test/test_sequence.py @@ -17,8 +17,11 @@ from bsddb.test.test_all import verbose class DBSequenceTest(unittest.TestCase): def setUp(self): self.int_32_max = 0x100000000 - self.homeDir = tempfile.mkdtemp() - old_tempfile_tempdir = tempfile.tempdir + self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + 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 diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py index 4a75384..a347911 100644 --- a/Lib/bsddb/test/test_thread.py +++ b/Lib/bsddb/test/test_thread.py @@ -47,7 +47,12 @@ class BaseThreadedTestCase(unittest.TestCase): if verbose: dbutils._deadlock_VerboseFile = sys.stdout - self.homeDir = tempfile.mkdtemp() + homeDir = os.path.join(tempfile.gettempdir(), 'db_home') + self.homeDir = homeDir + try: + os.mkdir(homeDir) + except OSError, e: + if e.errno != errno.EEXIST: raise self.env = db.DBEnv() self.setEnvOpts() self.env.open(self.homeDir, self.envflags | db.DB_CREATE) @@ -61,7 +66,10 @@ class BaseThreadedTestCase(unittest.TestCase): def tearDown(self): self.d.close() self.env.close() - shutil.rmtree(self.homeDir) + try: + shutil.rmtree(self.homeDir) + except OSError, e: + if e.errno != errno.EEXIST: raise def setEnvOpts(self): pass |