[Python-checkins] python/dist/src/Lib/test test_tarfile.py,1.9,1.10

bcannon@users.sourceforge.net bcannon@users.sourceforge.net
Thu, 12 Jun 2003 01:01:09 -0700


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

Modified Files:
	test_tarfile.py 
Log Message:
Make creation of temporary file and directory more portable.  Also made cleanup
code use proper functions to get paths.

Changed the name of tar file that is searched for to be absolute (i.e., not use
os.extsep) since filename is locked in based on name of file in CVS
(testtar.tar).

Closes bug #731403 .


Index: test_tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_tarfile.py	10 May 2003 07:36:55 -0000	1.9
--- test_tarfile.py	12 Jun 2003 08:01:06 -0000	1.10
***************
*** 2,5 ****
--- 2,6 ----
  import os
  import shutil
+ import tempfile
  
  import unittest
***************
*** 22,28 ****
      return test_support.findfile(path)
  
! testtar = path("testtar" + os.extsep + "tar")
! tempdir = path("testtar" + os.extsep + "dir")
! tempname = path("testtar" + os.extsep + "tmp")
  membercount = 10
  
--- 23,29 ----
      return test_support.findfile(path)
  
! testtar = path("testtar.tar")
! tempdir = os.path.join(tempfile.gettempdir(), "testtar" + os.extsep + "dir")
! tempname = test_support.TESTFN
  membercount = 10
  
***************
*** 266,273 ****
          if bz2:
              os.remove(tarname("bz2"))
!         if os.path.exists(tempdir):
!             shutil.rmtree(tempdir)
!         if os.path.exists(tempname):
!             os.remove(tempname)
  
  if __name__ == "__main__":
--- 267,274 ----
          if bz2:
              os.remove(tarname("bz2"))
!         if os.path.exists(dirname()):
!             shutil.rmtree(dirname())
!         if os.path.exists(tmpname()):
!             os.remove(tmpname())
  
  if __name__ == "__main__":