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

@ -2,6 +2,7 @@
"""
import os
import shutil
import sys
import unittest
import tempfile
@ -18,22 +19,14 @@ except ImportError:
class MiscTestCase(unittest.TestCase):
def setUp(self):
self.filename = self.__class__.__name__ + '.db'
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
self.homeDir = homeDir
try:
os.mkdir(homeDir)
except OSError:
pass
self.homeDir = tempfile.mkdtemp()
def tearDown(self):
try:
os.remove(self.filename)
except OSError:
pass
import glob
files = glob.glob(os.path.join(self.homeDir, '*'))
for file in files:
os.remove(file)
shutil.rmtree(self.homeDir)
def test01_badpointer(self):
dbs = dbshelve.open(self.filename)