]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_spawn.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / tests / test_spawn.py
CommitLineData
4710c53d 1"""Tests for distutils.spawn."""\r
2import unittest\r
3import os\r
4import time\r
5from test.test_support import captured_stdout, run_unittest\r
6\r
7from distutils.spawn import _nt_quote_args\r
8from distutils.spawn import spawn, find_executable\r
9from distutils.errors import DistutilsExecError\r
10from distutils.tests import support\r
11\r
12class SpawnTestCase(support.TempdirManager,\r
13 support.LoggingSilencer,\r
14 unittest.TestCase):\r
15\r
16 def test_nt_quote_args(self):\r
17\r
18 for (args, wanted) in ((['with space', 'nospace'],\r
19 ['"with space"', 'nospace']),\r
20 (['nochange', 'nospace'],\r
21 ['nochange', 'nospace'])):\r
22 res = _nt_quote_args(args)\r
23 self.assertEqual(res, wanted)\r
24\r
25\r
26 @unittest.skipUnless(os.name in ('nt', 'posix'),\r
27 'Runs only under posix or nt')\r
28 def test_spawn(self):\r
29 tmpdir = self.mkdtemp()\r
30\r
31 # creating something executable\r
32 # through the shell that returns 1\r
33 if os.name == 'posix':\r
34 exe = os.path.join(tmpdir, 'foo.sh')\r
35 self.write_file(exe, '#!/bin/sh\nexit 1')\r
36 os.chmod(exe, 0777)\r
37 else:\r
38 exe = os.path.join(tmpdir, 'foo.bat')\r
39 self.write_file(exe, 'exit 1')\r
40\r
41 os.chmod(exe, 0777)\r
42 self.assertRaises(DistutilsExecError, spawn, [exe])\r
43\r
44 # now something that works\r
45 if os.name == 'posix':\r
46 exe = os.path.join(tmpdir, 'foo.sh')\r
47 self.write_file(exe, '#!/bin/sh\nexit 0')\r
48 os.chmod(exe, 0777)\r
49 else:\r
50 exe = os.path.join(tmpdir, 'foo.bat')\r
51 self.write_file(exe, 'exit 0')\r
52\r
53 os.chmod(exe, 0777)\r
54 spawn([exe]) # should work without any error\r
55\r
56def test_suite():\r
57 return unittest.makeSuite(SpawnTestCase)\r
58\r
59if __name__ == "__main__":\r
60 run_unittest(test_suite())\r