summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-03-17 18:05:03 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-03-17 18:05:03 (GMT)
commitbf69e0c3abf9392979f4b880c0c931d5cf53af78 (patch)
treed6a6f156fffda8311d6e99346a3e00c64d19d2a2
parent2de0ec6c1e680984fa911cfb23f7f7295f473853 (diff)
downloadcpython-bf69e0c3abf9392979f4b880c0c931d5cf53af78.zip
cpython-bf69e0c3abf9392979f4b880c0c931d5cf53af78.tar.gz
cpython-bf69e0c3abf9392979f4b880c0c931d5cf53af78.tar.bz2
Backport Tim's checkin of revision 1.5:
This test left a new set of 3 junk files behind each time it was run.
-rw-r--r--Lib/test/test_dumbdbm.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py
index d62c74d..5da4f3f 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dumbdbm.py
@@ -9,8 +9,16 @@ import unittest
import dumbdbm
import tempfile
+_fname = tempfile.mktemp()
+
+def _delete_files():
+ for ext in [".dir", ".dat", ".bak"]:
+ try:
+ os.unlink(_fname + ext)
+ except OSError:
+ pass
+
class DumbDBMTestCase(unittest.TestCase):
- _fname = tempfile.mktemp()
_dict = {'0': '',
'a': 'Python:',
'b': 'Programming',
@@ -26,11 +34,8 @@ class DumbDBMTestCase(unittest.TestCase):
self._dkeys.sort()
def test_dumbdbm_creation(self):
- for ext in [".dir", ".dat", ".bak"]:
- try: os.unlink(self._fname+ext)
- except OSError: pass
-
- f = dumbdbm.open(self._fname, 'c')
+ _delete_files()
+ f = dumbdbm.open(_fname, 'c')
self.assertEqual(f.keys(), [])
for key in self._dict:
f[key] = self._dict[key]
@@ -38,18 +43,18 @@ class DumbDBMTestCase(unittest.TestCase):
f.close()
def test_dumbdbm_modification(self):
- f = dumbdbm.open(self._fname, 'w')
+ f = dumbdbm.open(_fname, 'w')
self._dict['g'] = f['g'] = "indented"
self.read_helper(f)
f.close()
def test_dumbdbm_read(self):
- f = dumbdbm.open(self._fname, 'r')
+ f = dumbdbm.open(_fname, 'r')
self.read_helper(f)
f.close()
def test_dumbdbm_keys(self):
- f = dumbdbm.open(self._fname)
+ f = dumbdbm.open(_fname)
keys = self.keys_helper(f)
f.close()
@@ -65,8 +70,10 @@ class DumbDBMTestCase(unittest.TestCase):
return keys
def test_main():
- test_support.run_unittest(DumbDBMTestCase)
-
+ try:
+ test_support.run_unittest(DumbDBMTestCase)
+ finally:
+ _delete_files()
if __name__ == "__main__":
test_main()