aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarek <none@none>2009-07-23 12:29:31 +0200
committertarek <none@none>2009-07-23 12:29:31 +0200
commit8e59ae90b1dcfb8cab7255509b2d13bfc96a516e (patch)
tree50b099849ec4cd572163c23840aaef5ae0be08fb
parentdb1f56a5908aebb6e26f30cefc77f37c39b0e684 (diff)
downloadexternal_python_setuptools-8e59ae90b1dcfb8cab7255509b2d13bfc96a516e.tar.gz
external_python_setuptools-8e59ae90b1dcfb8cab7255509b2d13bfc96a516e.tar.bz2
external_python_setuptools-8e59ae90b1dcfb8cab7255509b2d13bfc96a516e.zip
safer test: will not overwrite an existing file for the test
--HG-- branch : distribute extra : rebase_source : f7eb15a38641127ee2eabdf9aedce9df4e79d581
-rw-r--r--tests/install_test.py43
1 files changed, 30 insertions, 13 deletions
diff --git a/tests/install_test.py b/tests/install_test.py
index 11fc2cb6..52a46c00 100644
--- a/tests/install_test.py
+++ b/tests/install_test.py
@@ -2,6 +2,10 @@ import urllib2
import sys
import os
+if os.path.exists('bootstrap.py'):
+ print 'bootstrap.py exists in the current dir, aborting'
+ sys.exit(2)
+
print '**** Starting Test'
print '\n\n'
@@ -33,20 +37,33 @@ except ImportError:
sys.exit(hasattr(setuptools, "_distribute"))
"""
-f = open('script.py', 'w')
-f.write(script)
-f.close()
+root = 'script'
+seed = 0
+script_name = '%s%d.py' % (root, seed)
-args = [sys.executable] + ['script.py']
+while os.path.exists(script_name):
+ seed += 1
+ script_name = '%s%d.py' % (root, seed)
-if is_jython:
- res = subprocess.call([sys.executable] + args)
-else:
- res = os.spawnv(os.P_WAIT, sys.executable, args)
+f = open(script_name, 'w')
+try:
+ f.write(script)
+finally:
+ f.close()
-print '\n\n'
-if res:
- print '**** Test is OK'
-else:
- print '**** Test failed, please send me the output at tarek@ziade.org'
+try:
+ args = [sys.executable] + ['script.py']
+ if is_jython:
+ res = subprocess.call([sys.executable] + args)
+ else:
+ res = os.spawnv(os.P_WAIT, sys.executable, args)
+
+ print '\n\n'
+ if res:
+ print '**** Test is OK'
+ else:
+ print '**** Test failed, please send me the output at tarek@ziade.org'
+finally:
+ os.remove(script_name)
+ os.remove('bootstrap.py')