summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-11-03 00:35:53 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-11-03 00:35:53 (GMT)
commit26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768 (patch)
tree167e2225e370e7782a8d479644fe736b3d7b813f
parent034c749ff4d9be0e6ee79943acb8c70d7386b11d (diff)
downloadcpython-26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768.zip
cpython-26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768.tar.gz
cpython-26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768.tar.bz2
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. Will backport.
-rw-r--r--Lib/test/test_support.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index c720f43..8aab9de 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -97,7 +97,27 @@ elif os.name != 'riscos':
TESTFN_ENCODING="mbcs"
else:
TESTFN = 'test'
-del os
+
+# 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