summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test/test_dbtables.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-10-18 17:15:20 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2007-10-18 17:15:20 (GMT)
commit0dcc3cc94926c76223d41a0b36f4c0792ec47089 (patch)
treea43760cf95e0affb91fb3af33e20d79cddff3d98 /Lib/bsddb/test/test_dbtables.py
parent574e1ba814b19aafa93519f953529b35aab9fa12 (diff)
downloadcpython-0dcc3cc94926c76223d41a0b36f4c0792ec47089.zip
cpython-0dcc3cc94926c76223d41a0b36f4c0792ec47089.tar.gz
cpython-0dcc3cc94926c76223d41a0b36f4c0792ec47089.tar.bz2
Backport 58532, 58533, 58534:
- Fix bsddb.dbtables: Don't randomly corrupt newly inserted rows by picking a rowid string with null bytes in it. Such rows could not later be deleted, modified or individually selected. Existing bsdTableDb databases created with such rows are out of luck. - Use mkdtemp for the test_dbtables test database environment and clean it up afterwards using shutil.rmtree.
Diffstat (limited to 'Lib/bsddb/test/test_dbtables.py')
-rw-r--r--Lib/bsddb/test/test_dbtables.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index 26e3d36..7bcc2a7 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -21,9 +21,10 @@
# $Id$
import sys, os, re
+import shutil
+import tempfile
try:
- import cPickle
- pickle = cPickle
+ import cPickle as pickle
except ImportError:
import pickle
@@ -42,12 +43,9 @@ except ImportError:
#----------------------------------------------------------------------
class TableDBTestCase(unittest.TestCase):
- db_home = 'db_home'
- db_name = 'test-table.db'
-
def setUp(self):
- homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
- self.homeDir = homeDir
+ homeDir = tempfile.mkdtemp()
+ self.testHomeDir = homeDir
try: os.mkdir(homeDir)
except os.error: pass
self.tdb = dbtables.bsdTableDB(
@@ -55,10 +53,7 @@ class TableDBTestCase(unittest.TestCase):
def tearDown(self):
self.tdb.close()
- import glob
- files = glob.glob(os.path.join(self.homeDir, '*'))
- for file in files:
- os.remove(file)
+ shutil.rmtree(self.testHomeDir)
def test01(self):
tabname = "test01"