summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2002-03-17 23:03:42 (GMT)
committerSkip Montanaro <skip@pobox.com>2002-03-17 23:03:42 (GMT)
commitc08fe82b32386d2621f4c6c17cc334c7a3a924b9 (patch)
tree4aa8f83b57a4fceddd8e8c6070f93e7673a88b5c
parent03d3e33af92a8bcc4e8bac05ed71a1e77b833719 (diff)
downloadcpython-c08fe82b32386d2621f4c6c17cc334c7a3a924b9.zip
cpython-c08fe82b32386d2621f4c6c17cc334c7a3a924b9.tar.gz
cpython-c08fe82b32386d2621f4c6c17cc334c7a3a924b9.tar.bz2
restructure a bit to not rely on test case execution ordering
add test case for bug #482460
-rw-r--r--Lib/test/test_dumbdbm.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py
index 5da4f3f..f3675a5 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dumbdbm.py
@@ -30,11 +30,8 @@ class DumbDBMTestCase(unittest.TestCase):
def __init__(self, *args):
unittest.TestCase.__init__(self, *args)
- self._dkeys = self._dict.keys()
- self._dkeys.sort()
def test_dumbdbm_creation(self):
- _delete_files()
f = dumbdbm.open(_fname, 'c')
self.assertEqual(f.keys(), [])
for key in self._dict:
@@ -43,32 +40,59 @@ class DumbDBMTestCase(unittest.TestCase):
f.close()
def test_dumbdbm_modification(self):
+ self.init_db()
f = dumbdbm.open(_fname, 'w')
self._dict['g'] = f['g'] = "indented"
self.read_helper(f)
f.close()
def test_dumbdbm_read(self):
+ self.init_db()
f = dumbdbm.open(_fname, 'r')
self.read_helper(f)
f.close()
def test_dumbdbm_keys(self):
+ self.init_db()
f = dumbdbm.open(_fname)
keys = self.keys_helper(f)
f.close()
+ def test_write_write_read(self):
+ # test for bug #482460
+ f = dumbdbm.open(_fname)
+ f['1'] = 'hello'
+ f['1'] = 'hello2'
+ f.close()
+ f = dumbdbm.open(_fname)
+ self.assertEqual(f['1'], 'hello2')
+ f.close()
+
def read_helper(self, f):
keys = self.keys_helper(f)
for key in self._dict:
self.assertEqual(self._dict[key], f[key])
+ def init_db(self):
+ f = dumbdbm.open(_fname, 'w')
+ for k in self._dict:
+ f[k] = self._dict[k]
+ f.close()
+
def keys_helper(self, f):
keys = f.keys()
keys.sort()
- self.assertEqual(keys, self._dkeys)
+ dkeys = self._dict.keys()
+ dkeys.sort()
+ self.assertEqual(keys, dkeys)
return keys
+ def tearDown(self):
+ _delete_files()
+
+ def setUp(self):
+ _delete_files()
+
def test_main():
try:
test_support.run_unittest(DumbDBMTestCase)