summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test/test_pickle.py
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2008-08-31 14:12:11 (GMT)
committerJesus Cea <jcea@jcea.es>2008-08-31 14:12:11 (GMT)
commit6ba3329c274e2c7876c61f2e98d4592310d26bae (patch)
tree6bb346e892269279fa2011c3e4bd4648b273a7ae /Lib/bsddb/test/test_pickle.py
parent73c96dbf34c70bbf1ef807b98d51cf9c0e9dc042 (diff)
downloadcpython-6ba3329c274e2c7876c61f2e98d4592310d26bae.zip
cpython-6ba3329c274e2c7876c61f2e98d4592310d26bae.tar.gz
cpython-6ba3329c274e2c7876c61f2e98d4592310d26bae.tar.bz2
bsddb code updated to version 4.7.3pre2. This code is the same than
Python 2.6 one, since the intention is to keep an unified 2.x/3.x codebase. The Python code is automatically translated using "2to3". Please, do not update this code in Python 3.0 by hand. Update the 2.6 one and then do "2to3".
Diffstat (limited to 'Lib/bsddb/test/test_pickle.py')
-rw-r--r--Lib/bsddb/test/test_pickle.py37
1 files changed, 14 insertions, 23 deletions
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py
index c1175e6..a8d9199 100644
--- a/Lib/bsddb/test/test_pickle.py
+++ b/Lib/bsddb/test/test_pickle.py
@@ -1,23 +1,13 @@
-import shutil
-import sys, os
+import os
import pickle
-import tempfile
-import unittest
-import tempfile
-
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db
-except ImportError as e:
- # For Python 2.3
- from bsddb import db
-
try:
- from bsddb3 import test_support
+ import pickle
except ImportError:
- from test import support as test_support
+ pickle = None
+import unittest
+from .test_all import db, test_support, get_new_environment_path, get_new_database_path
#----------------------------------------------------------------------
@@ -26,10 +16,7 @@ class pickleTestCase(unittest.TestCase):
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'):
@@ -43,10 +30,10 @@ class pickleTestCase(unittest.TestCase):
self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
self.db = db.DB(self.env)
self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
- self.db.put(b'spam', b'eggs')
- self.assertEqual(self.db[b'spam'], b'eggs')
+ self.db.put('spam', 'eggs')
+ self.assertEqual(self.db['spam'], 'eggs')
try:
- self.db.put(b'spam', b'ham', flags=db.DB_NOOVERWRITE)
+ self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
except db.DBError as egg:
pickledEgg = pickle.dumps(egg)
#print repr(pickledEgg)
@@ -54,7 +41,7 @@ class pickleTestCase(unittest.TestCase):
if rottenEgg.args != egg.args or type(rottenEgg) != type(egg):
raise Exception(rottenEgg, '!=', egg)
else:
- self.fail("where's my DBError exception?!?")
+ raise Exception("where's my DBError exception?!?")
self.db.close()
self.env.close()
@@ -62,6 +49,10 @@ class pickleTestCase(unittest.TestCase):
def test01_pickle_DBError(self):
self._base_test_pickle_DBError(pickle=pickle)
+ if pickle:
+ def test02_cPickle_DBError(self):
+ self._base_test_pickle_DBError(pickle=pickle)
+
#----------------------------------------------------------------------
def test_suite():