diff options
| author | Gregory P. Smith <greg@mad-scientist.com> | 2007-08-28 08:05:56 (GMT) |
|---|---|---|
| committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-08-28 08:05:56 (GMT) |
| commit | 3fd22da6129040fdea850bf593e63fc8c333304b (patch) | |
| tree | c7ce98ab685a138c745048f0314c9007b9d99996 /Lib/bsddb/test/test_pickle.py | |
| parent | a280ca759492360fd7440476f513fa9726d22bff (diff) | |
| download | cpython-3fd22da6129040fdea850bf593e63fc8c333304b.zip cpython-3fd22da6129040fdea850bf593e63fc8c333304b.tar.gz cpython-3fd22da6129040fdea850bf593e63fc8c333304b.tar.bz2 | |
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.
Diffstat (limited to 'Lib/bsddb/test/test_pickle.py')
| -rw-r--r-- | Lib/bsddb/test/test_pickle.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py index 66d421c..3bedab7 100644 --- a/Lib/bsddb/test/test_pickle.py +++ b/Lib/bsddb/test/test_pickle.py @@ -1,6 +1,8 @@ +import shutil import sys, os import pickle +import tempfile import unittest import glob @@ -16,33 +18,27 @@ except ImportError as e: class pickleTestCase(unittest.TestCase): """Verify that DBError can be pickled and unpickled""" - db_home = 'db_home' db_name = 'test-dbobj.db' def setUp(self): - homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') - self.homeDir = homeDir - try: os.mkdir(homeDir) - except os.error: pass + self.homeDir = tempfile.mkdtemp() def tearDown(self): if hasattr(self, 'db'): del self.db if hasattr(self, 'env'): del self.env - files = glob.glob(os.path.join(self.homeDir, '*')) - for file in files: - os.remove(file) + shutil.rmtree(self.homeDir) def _base_test_pickle_DBError(self, pickle): self.env = db.DBEnv() 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('spam', 'eggs') - assert self.db['spam'] == 'eggs' + self.db.put(b'spam', b'eggs') + self.assertEqual(self.db[b'spam'], b'eggs') try: - self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE) + self.db.put(b'spam', b'ham', flags=db.DB_NOOVERWRITE) except db.DBError as egg: pickledEgg = pickle.dumps(egg) #print repr(pickledEgg) @@ -50,7 +46,7 @@ class pickleTestCase(unittest.TestCase): if rottenEgg.args != egg.args or type(rottenEgg) != type(egg): raise Exception(rottenEgg, '!=', egg) else: - raise Exception("where's my DBError exception?!?") + self.fail("where's my DBError exception?!?") self.db.close() self.env.close() |
