summaryrefslogtreecommitdiff
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-01-29 01:56:10 +0000
committerGregory P. Smith <greg@krypto.org>2018-01-28 17:56:10 -0800
commit6c6ddf97c402709713d668d0ed53836a7749ba99 (patch)
treee403bfbc134daea26026db43b207bbdb203019fa /Lib/test/test_posix.py
parentf5b04a360e44aa9733f7a92dd66d2292d6c52955 (diff)
downloadcpython-git-6c6ddf97c402709713d668d0ed53836a7749ba99.tar.gz
bpo-20104: Expose `posix_spawn` in the os module (GH-5109)
Add os.posix_spawn to wrap the low level POSIX API of the same name. Contributed by Pablo Galindo.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index a7f3d34f66..8ada0e3ab3 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -176,6 +176,23 @@ class PosixTester(unittest.TestCase):
finally:
os.close(fp)
+
+ @unittest.skipUnless(hasattr(os, 'posix_spawn'), "test needs os.posix_spawn")
+ def test_posix_spawn(self):
+ pid = posix.posix_spawn(sys.executable, [sys.executable, "-c", "pass"], os.environ,[])
+ self.assertEqual(os.waitpid(pid,0),(pid,0))
+
+
+ @unittest.skipUnless(hasattr(os, 'posix_spawn'), "test needs os.posix_spawn")
+ def test_posix_spawn_file_actions(self):
+ file_actions = []
+ file_actions.append((0,3,os.path.realpath(__file__),0,0))
+ file_actions.append((os.POSIX_SPAWN_CLOSE,2))
+ file_actions.append((os.POSIX_SPAWN_DUP2,1,4))
+ pid = posix.posix_spawn(sys.executable, [sys.executable, "-c", "pass"], os.environ, file_actions)
+ self.assertEqual(os.waitpid(pid,0),(pid,0))
+
+
@unittest.skipUnless(hasattr(posix, 'waitid'), "test needs posix.waitid()")
@unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
def test_waitid(self):