some test suite cleanup, use tempfile.mkdtemp() in setUp and

shutil.rmtree() in tearDown().  add missing tests to the list
in the test_bsddb3 suite.
This commit is contained in:
Gregory P. Smith 2007-08-28 08:05:56 +00:00
parent a280ca7594
commit 3fd22da612
22 changed files with 180 additions and 229 deletions

View file

@ -1,5 +1,7 @@
import unittest
import sys, os, glob
import shutil
import tempfile
from bsddb import db
@ -11,11 +13,7 @@ class pget_bugTestCase(unittest.TestCase):
db_name = 'test-cursor_pget.db'
def setUp(self):
self.homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
try:
os.mkdir(self.homeDir)
except os.error:
pass
self.homeDir = tempfile.mkdtemp()
self.env = db.DBEnv()
self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
self.primary_db = db.DB(self.env)
@ -36,9 +34,7 @@ class pget_bugTestCase(unittest.TestCase):
del self.secondary_db
del self.primary_db
del self.env
for file in glob.glob(os.path.join(self.homeDir, '*')):
os.remove(file)
os.removedirs(self.homeDir)
shutil.rmtree(self.homeDir)
def test_pget(self):
cursor = self.secondary_db.cursor()