summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test/test_thread.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-02-24 18:47:03 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2008-02-24 18:47:03 (GMT)
commit6057b2e645dd3b7a262553d5a547ef45d3fc5d93 (patch)
tree2cc98747bc937c53e079e115fa98ee39cddb447f /Lib/bsddb/test/test_thread.py
parent6a123cb7827859748a0096570dfbb5ceba0e59dc (diff)
downloadcpython-6057b2e645dd3b7a262553d5a547ef45d3fc5d93.zip
cpython-6057b2e645dd3b7a262553d5a547ef45d3fc5d93.tar.gz
cpython-6057b2e645dd3b7a262553d5a547ef45d3fc5d93.tar.bz2
Create a db_home directory with a unique name so multiple users can
run the test simultaneously. The simplest thing I found that worked on both Windows and Unix was to use the PID. It's unique so should be sufficient. This should prevent many of the spurious failures of the automated tests since they run as different users. Also cleanup the directory consistenly in the tearDown methods. It would be nice if someone ensured that the directories are always created with a consistent name.
Diffstat (limited to 'Lib/bsddb/test/test_thread.py')
-rw-r--r--Lib/bsddb/test/test_thread.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
index d14f6da..8a8b313 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 random import random
@@ -52,7 +51,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)
@@ -69,12 +68,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, e:
- if e.errno != errno.EEXIST: raise
def setEnvOpts(self):
pass