@@ -3348,6 +3348,7 @@ def exit_handler():
3348
3348
@unittest .skipIf (not sysconfig .get_config_var ("HAVE_VFORK" ),
3349
3349
"vfork() not enabled by configure." )
3350
3350
@mock .patch ("subprocess._fork_exec" )
3351
+ @mock .patch ("subprocess._USE_POSIX_SPAWN" ,new = False )
3351
3352
def test__use_vfork (self ,mock_fork_exec ):
3352
3353
self .assertTrue (subprocess ._USE_VFORK )# The default value regardless.
3353
3354
mock_fork_exec .side_effect = RuntimeError ("just testing args" )
@@ -3366,9 +3367,13 @@ def test__use_vfork(self, mock_fork_exec):
3366
3367
@unittest .skipIf (not sysconfig .get_config_var ("HAVE_VFORK" ),
3367
3368
"vfork() not enabled by configure." )
3368
3369
@unittest .skipIf (sys .platform != "linux" ,"Linux only, requires strace." )
3370
+ @mock .patch ("subprocess._USE_POSIX_SPAWN" ,new = False )
3369
3371
def test_vfork_used_when_expected (self ):
3370
3372
# This is a performance regression test to ensure we default to using
3371
3373
# vfork() when possible.
3374
+ # Technically this test could pass when posix_spawn is used as well
3375
+ # because libc tends to implement that internally using vfork. But
3376
+ # that'd just be testing a libc+kernel implementation detail.
3372
3377
strace_binary = "/usr/bin/strace"
3373
3378
# The only system calls we are interested in.
3374
3379
strace_filter = "--trace=clone,clone2,clone3,fork,vfork,exit,exit_group"