[Python-checkins] CVS: python/dist/src/Lib/test test_dumbdbm.py,1.4,1.5

Tim Peters tim_one@users.sourceforge.net
Tue, 29 Jan 2002 23:32:55 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv20259

Modified Files:
	test_dumbdbm.py 
Log Message:
This test left a new set of 3 junk files behind each time it was run.


Index: test_dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dumbdbm.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_dumbdbm.py	2001/11/13 21:51:26	1.4
--- test_dumbdbm.py	2002/01/30 07:32:53	1.5
***************
*** 10,15 ****
  import tempfile
  
  class DumbDBMTestCase(unittest.TestCase):
-     _fname = tempfile.mktemp()
      _dict = {'0': '',
               'a': 'Python:',
--- 10,23 ----
  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):
      _dict = {'0': '',
               'a': 'Python:',
***************
*** 27,35 ****
  
      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')
          self.assertEqual(f.keys(), [])
          for key in self._dict:
--- 35,40 ----
  
      def test_dumbdbm_creation(self):
!         _delete_files()
!         f = dumbdbm.open(_fname, 'c')
          self.assertEqual(f.keys(), [])
          for key in self._dict:
***************
*** 39,43 ****
  
      def test_dumbdbm_modification(self):
!         f = dumbdbm.open(self._fname, 'w')
          self._dict['g'] = f['g'] = "indented"
          self.read_helper(f)
--- 44,48 ----
  
      def test_dumbdbm_modification(self):
!         f = dumbdbm.open(_fname, 'w')
          self._dict['g'] = f['g'] = "indented"
          self.read_helper(f)
***************
*** 45,54 ****
  
      def test_dumbdbm_read(self):
!         f = dumbdbm.open(self._fname, 'r')
          self.read_helper(f)
          f.close()
  
      def test_dumbdbm_keys(self):
!         f = dumbdbm.open(self._fname)
          keys = self.keys_helper(f)
          f.close()
--- 50,59 ----
  
      def test_dumbdbm_read(self):
!         f = dumbdbm.open(_fname, 'r')
          self.read_helper(f)
          f.close()
  
      def test_dumbdbm_keys(self):
!         f = dumbdbm.open(_fname)
          keys = self.keys_helper(f)
          f.close()
***************
*** 66,71 ****
  
  def test_main():
!     test_support.run_unittest(DumbDBMTestCase)
! 
  
  if __name__ == "__main__":
--- 71,78 ----
  
  def test_main():
!     try:
!         test_support.run_unittest(DumbDBMTestCase)
!     finally:
!         _delete_files()
  
  if __name__ == "__main__":