@@ -505,7 +505,7 @@ def test_daemon_param(self):
505
505
t = threading .Thread (daemon = True )
506
506
self .assertTrue (t .daemon )
507
507
508
- @unittest . skipUnless ( hasattr ( os , 'fork' ), 'needs os.fork()' )
508
+ @support . requires_fork ( )
509
509
def test_fork_at_exit (self ):
510
510
# bpo-42350: Calling os.fork() after threading._shutdown() must
511
511
# not log an error.
@@ -533,7 +533,7 @@ def exit_handler():
533
533
self .assertEqual (out , b'' )
534
534
self .assertEqual (err .rstrip (), b'child process ok' )
535
535
536
- @unittest . skipUnless ( hasattr ( os , 'fork' ), 'test needs fork()' )
536
+ @support . requires_fork ( )
537
537
def test_dummy_thread_after_fork (self ):
538
538
# Issue #14308: a dummy thread in the active list doesn't mess up
539
539
# the after-fork mechanism.
@@ -560,7 +560,7 @@ def background_thread(evt):
560
560
self .assertEqual (out , b'' )
561
561
self .assertEqual (err , b'' )
562
562
563
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "needs os.fork()" )
563
+ @support . requires_fork ( )
564
564
def test_is_alive_after_fork (self ):
565
565
# Try hard to trigger #18418: is_alive() could sometimes be True on
566
566
# threads that vanished after a fork.
@@ -594,7 +594,7 @@ def f():
594
594
th .start ()
595
595
th .join ()
596
596
597
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "test needs os.fork()" )
597
+ @support . requires_fork ( )
598
598
@unittest .skipUnless (hasattr (os , 'waitpid' ), "test needs os.waitpid()" )
599
599
def test_main_thread_after_fork (self ):
600
600
code = """if 1:
@@ -616,7 +616,7 @@ def test_main_thread_after_fork(self):
616
616
self .assertEqual (data , "MainThread\n True\n True\n " )
617
617
618
618
@unittest .skipIf (sys .platform in platforms_to_skip , "due to known OS bug" )
619
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "test needs os.fork()" )
619
+ @support . requires_fork ( )
620
620
@unittest .skipUnless (hasattr (os , 'waitpid' ), "test needs os.waitpid()" )
621
621
def test_main_thread_after_fork_from_nonmain_thread (self ):
622
622
code = """if 1:
@@ -993,7 +993,7 @@ def test_1_join_on_shutdown(self):
993
993
"""
994
994
self ._run_and_join (script )
995
995
996
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "needs os.fork()" )
996
+ @support . requires_fork ( )
997
997
@unittest .skipIf (sys .platform in platforms_to_skip , "due to known OS bug" )
998
998
def test_2_join_in_forked_process (self ):
999
999
# Like the test above, but from a forked interpreter
@@ -1014,7 +1014,7 @@ def test_2_join_in_forked_process(self):
1014
1014
"""
1015
1015
self ._run_and_join (script )
1016
1016
1017
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "needs os.fork()" )
1017
+ @support . requires_fork ( )
1018
1018
@unittest .skipIf (sys .platform in platforms_to_skip , "due to known OS bug" )
1019
1019
def test_3_join_in_forked_from_thread (self ):
1020
1020
# Like the test above, but fork() was called from a worker thread
@@ -1085,7 +1085,7 @@ def main():
1085
1085
rc , out , err = assert_python_ok ('-c' , script )
1086
1086
self .assertFalse (err )
1087
1087
1088
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "needs os.fork()" )
1088
+ @support . requires_fork ( )
1089
1089
@unittest .skipIf (sys .platform in platforms_to_skip , "due to known OS bug" )
1090
1090
def test_reinit_tls_after_fork (self ):
1091
1091
# Issue #13817: fork() would deadlock in a multithreaded program with
@@ -1109,7 +1109,7 @@ def do_fork_and_wait():
1109
1109
for t in threads :
1110
1110
t .join ()
1111
1111
1112
- @unittest . skipUnless ( hasattr ( os , 'fork' ), "needs os.fork()" )
1112
+ @support . requires_fork ( )
1113
1113
def test_clear_threads_states_after_fork (self ):
1114
1114
# Issue #17094: check that threads states are cleared after fork()
1115
1115
0 commit comments