File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 77import socket
88import tempfile
99import errno
10+ import textwrap
1011from test import support
12+ from test .support import script_helper
1113
1214TESTFN = support .TESTFN
1315
@@ -164,16 +166,18 @@ def test_temp_dir__existing_dir__quiet_true(self):
164166 @unittest .skipUnless (hasattr (os , "fork" ), "test requires os.fork" )
165167 def test_temp_dir__forked_child (self ):
166168 """Test that a forked child process does not remove the directory."""
167- with support .temp_cwd () as temp_path :
168- pid = os .fork ()
169- if pid != 0 :
170- # parent process
171- os .waitpid (pid , 0 ) # wait for the child to terminate
172- # make sure that temp_path is still present
173- self .assertTrue (os .path .isdir (temp_path ))
174- if pid == 0 :
175- # terminate the child in order to not confuse the test runner
176- os ._exit (0 )
169+ # Run the test as an external script, because it uses fork.
170+ script_helper .assert_python_ok ("-c" , textwrap .dedent ("""
171+ import os
172+ from test import support
173+ with support.temp_cwd() as temp_path:
174+ pid = os.fork()
175+ if pid != 0:
176+ # parent process
177+ os.waitpid(pid, 0) # wait for the child to terminate
178+ # make sure that temp_path is still present
179+ assert os.path.isdir(temp_path), "Child removed temp_path."
180+ """ ))
177181
178182 # Tests for change_cwd()
179183
You can’t perform that action at this time.
0 commit comments