summaryrefslogtreecommitdiff
path: root/tests/test_spawn.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-06-02 16:18:55 +0000
committerTarek Ziadé <ziade.tarek@gmail.com>2009-06-02 16:18:55 +0000
commit38fc75e0ef9b8b57879ea2d405fab4818f7b7aa1 (patch)
treebc4261668fc18133b771c24a0bc59b12a4d62105 /tests/test_spawn.py
parent4178fcef5d4b1fc1a9bc415c47c94ad6d33e3491 (diff)
downloadpython-setuptools-git-38fc75e0ef9b8b57879ea2d405fab4818f7b7aa1.tar.gz
Merged revisions 73147 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r73147 | tarek.ziade | 2009-06-02 17:58:43 +0200 (Tue, 02 Jun 2009) | 1 line improved distutils.spawn test coverage + cleaned it up ........
Diffstat (limited to 'tests/test_spawn.py')
-rw-r--r--tests/test_spawn.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/test_spawn.py b/tests/test_spawn.py
index 33e8bcf6..950e5789 100644
--- a/tests/test_spawn.py
+++ b/tests/test_spawn.py
@@ -1,8 +1,17 @@
"""Tests for distutils.spawn."""
import unittest
+import os
+import time
+from test.support import captured_stdout
+
from distutils.spawn import _nt_quote_args
+from distutils.spawn import spawn, find_executable
+from distutils.errors import DistutilsExecError
+from distutils.tests import support
-class SpawnTestCase(unittest.TestCase):
+class SpawnTestCase(support.TempdirManager,
+ support.LoggingSilencer,
+ unittest.TestCase):
def test_nt_quote_args(self):
@@ -13,6 +22,35 @@ class SpawnTestCase(unittest.TestCase):
res = _nt_quote_args(args)
self.assertEquals(res, wanted)
+
+ @unittest.skipUnless(os.name in ('nt', 'posix'),
+ 'Runs only under posix or nt')
+ def test_spawn(self):
+ tmpdir = self.mkdtemp()
+
+ # creating something executable
+ # through the shell that returns 1
+ if os.name == 'posix':
+ exe = os.path.join(tmpdir, 'foo.sh')
+ self.write_file(exe, '#!/bin/sh\nexit 1')
+ else:
+ exe = os.path.join(tmpdir, 'foo.bat')
+ self.write_file(exe, 'exit 1')
+
+ os.chmod(exe, 0o777)
+ self.assertRaises(DistutilsExecError, spawn, [exe])
+
+ # now something that works
+ if os.name == 'posix':
+ exe = os.path.join(tmpdir, 'foo.sh')
+ self.write_file(exe, '#!/bin/sh\nexit 0')
+ else:
+ exe = os.path.join(tmpdir, 'foo.bat')
+ self.write_file(exe, 'exit 0')
+
+ os.chmod(exe, 0o777)
+ spawn([exe]) # should work without any error
+
def test_suite():
return unittest.makeSuite(SpawnTestCase)