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

Michael Hudson mwh@users.sourceforge.net
Sun, 17 Mar 2002 10:05:05 -0800


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

Modified Files:
      Tag: release22-maint
	test_dumbdbm.py 
Log Message:
Backport Tim's checkin of revision 1.5:

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.4.8.1
diff -C2 -d -r1.4 -r1.4.8.1
*** test_dumbdbm.py	13 Nov 2001 21:51:26 -0000	1.4
--- test_dumbdbm.py	17 Mar 2002 18:05:03 -0000	1.4.8.1
***************
*** 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__":