[Python-3000-checkins] r55443 - python/branches/py3k-struni/Lib/test/test_shelve.py

guido.van.rossum python-3000-checkins at python.org
Fri May 18 23:57:10 CEST 2007


Author: guido.van.rossum
Date: Fri May 18 23:57:09 2007
New Revision: 55443

Modified:
   python/branches/py3k-struni/Lib/test/test_shelve.py
Log:
Fix the cleanup so that we're not left with shelftemp.db.* files.
This does nothing to fix the tests though...


Modified: python/branches/py3k-struni/Lib/test/test_shelve.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_shelve.py	(original)
+++ python/branches/py3k-struni/Lib/test/test_shelve.py	Fri May 18 23:57:09 2007
@@ -8,35 +8,33 @@
 
     fn = "shelftemp" + os.extsep + "db"
 
+    def tearDown(self):
+        for f in glob.glob(self.fn+"*"):
+            os.unlink(f)
+
     def test_ascii_file_shelf(self):
+        s = shelve.open(self.fn, protocol=0)
         try:
-            s = shelve.open(self.fn, protocol=0)
             s['key1'] = (1,2,3,4)
             self.assertEqual(s['key1'], (1,2,3,4))
-            s.close()
         finally:
-            for f in glob.glob(self.fn+"*"):
-                os.unlink(f)
+            s.close()
 
     def test_binary_file_shelf(self):
+        s = shelve.open(self.fn, protocol=1)
         try:
-            s = shelve.open(self.fn, protocol=1)
             s['key1'] = (1,2,3,4)
             self.assertEqual(s['key1'], (1,2,3,4))
-            s.close()
         finally:
-            for f in glob.glob(self.fn+"*"):
-                os.unlink(f)
+            s.close()
 
     def test_proto2_file_shelf(self):
+        s = shelve.open(self.fn, protocol=2)
         try:
-            s = shelve.open(self.fn, protocol=2)
             s['key1'] = (1,2,3,4)
             self.assertEqual(s['key1'], (1,2,3,4))
-            s.close()
         finally:
-            for f in glob.glob(self.fn+"*"):
-                os.unlink(f)
+            s.close()
 
     def test_in_memory_shelf(self):
         d1 = {}


More information about the Python-3000-checkins mailing list