summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test/test_dbobj.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/bsddb/test/test_dbobj.py')
-rw-r--r--Lib/bsddb/test/test_dbobj.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
index c15face..2af88ba 100644
--- a/Lib/bsddb/test/test_dbobj.py
+++ b/Lib/bsddb/test/test_dbobj.py
@@ -1,7 +1,6 @@
import os, string
import unittest
-import tempfile
try:
# For Pythons w/distutils pybsddb
@@ -10,24 +9,21 @@ except ImportError:
# For Python 2.3
from bsddb import db, dbobj
+from test_all import get_new_environment_path, get_new_database_path
+
try:
from bsddb3 import test_support
except ImportError:
from test import test_support
-
#----------------------------------------------------------------------
class dbobjTestCase(unittest.TestCase):
"""Verify that dbobj.DB and dbobj.DBEnv work properly"""
- db_home = 'db_home'
db_name = 'test-dbobj.db'
def setUp(self):
- homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
- self.homeDir = homeDir
- try: os.mkdir(homeDir)
- except os.error: pass
+ self.homeDir = get_new_environment_path()
def tearDown(self):
if hasattr(self, 'db'):
@@ -48,10 +44,10 @@ class dbobjTestCase(unittest.TestCase):
self.db = TestDB(self.env)
self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
self.db.put('spam', 'eggs')
- assert self.db.get('spam') == None, \
- "overridden dbobj.DB.put() method failed [1]"
- assert self.db.get('SPAM') == 'eggs', \
- "overridden dbobj.DB.put() method failed [2]"
+ self.assertEqual(self.db.get('spam'), None,
+ "overridden dbobj.DB.put() method failed [1]")
+ self.assertEqual(self.db.get('SPAM'), 'eggs',
+ "overridden dbobj.DB.put() method failed [2]")
self.db.close()
self.env.close()
@@ -63,12 +59,12 @@ class dbobjTestCase(unittest.TestCase):
# __setitem__
self.db['spam'] = 'eggs'
# __len__
- assert len(self.db) == 1
+ self.assertEqual(len(self.db), 1)
# __getitem__
- assert self.db['spam'] == 'eggs'
+ self.assertEqual(self.db['spam'], 'eggs')
# __del__
del self.db['spam']
- assert self.db.get('spam') == None, "dbobj __del__ failed"
+ self.assertEqual(self.db.get('spam'), None, "dbobj __del__ failed")
self.db.close()
self.env.close()