[Python-checkins] python/dist/src/Lib/test test_support.py,1.40.8.1,1.40.8.2

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Sat, 02 Nov 2002 16:37:59 -0800


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

Modified Files:
      Tag: release22-maint
	test_support.py 
Log Message:
Fix SF # 631066, running regrtest in user mode fails

Try to write to TESTFN, if that fails, try TESTFN in /tmp
If that fails, print a warning and go on.


Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.40.8.1
retrieving revision 1.40.8.2
diff -C2 -d -r1.40.8.1 -r1.40.8.2
*** test_support.py	1 Nov 2002 19:12:55 -0000	1.40.8.1
--- test_support.py	3 Nov 2002 00:37:57 -0000	1.40.8.2
***************
*** 95,99 ****
  else:
      TESTFN = 'test'
! del os
  
  from os import unlink
--- 95,119 ----
  else:
      TESTFN = 'test'
! 
! # Make sure we can write to TESTFN, try in /tmp if we can't
! fp = None
! try:
!     fp = open(TESTFN, 'w+')
! except IOError:
!     TMP_TESTFN = os.path.join('/tmp', TESTFN)
!     try:
!         fp = open(TMP_TESTFN, 'w+')
!         TESTFN = TMP_TESTFN
!         del TMP_TESTFN
!     except IOError:
!         print ('WARNING: tests will fail, unable to write to: %s or %s' % 
!                 (TESTFN, TMP_TESTFN))
! if fp is not None:
!     fp.close()
!     try:
!         os.unlink(TESTFN)
!     except:
!         pass
! del os, fp
  
  from os import unlink