diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-06-02 16:18:55 (GMT) |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-06-02 16:18:55 (GMT) |
commit | 861d6449294f586ba0cc4e481a79579aff401229 (patch) | |
tree | 4d6b540e8819aa65ac60421ac3ff8f42860dd0a5 /Lib/distutils/tests | |
parent | 60fe6b045a6fa1374d7355a91ebde9d1d621e9e7 (diff) | |
download | cpython-861d6449294f586ba0cc4e481a79579aff401229.zip cpython-861d6449294f586ba0cc4e481a79579aff401229.tar.gz cpython-861d6449294f586ba0cc4e481a79579aff401229.tar.bz2 |
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 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/test_spawn.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py index 33e8bcf..950e578 100644 --- a/Lib/distutils/tests/test_spawn.py +++ b/Lib/distutils/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) |