From: Neal Norwitz Date: Sun, 3 Nov 2002 00:37:57 +0000 (+0000) Subject: Fix SF # 631066, running regrtest in user mode fails X-Git-Tag: v2.2.3c1~259 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4de21e1b23b6e9de4c18a718aa95eedcbc0c1261;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 3c814443c792..684b7712f8a4 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -94,7 +94,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