summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-01-16 21:52:43 (GMT)
committerGitHub <noreply@github.com>2022-01-16 21:52:43 (GMT)
commit91e33ac3d08a1c6004c469da2c0e2a97b5bdc53c (patch)
tree93e1ad6d692a706bd319b6c705642487499f4965 /Lib/test/test_threading.py
parent5cd9a162cd02a3d0f1b0a182d80feeb17439e84f (diff)
downloadcpython-91e33ac3d08a1c6004c469da2c0e2a97b5bdc53c.zip
cpython-91e33ac3d08a1c6004c469da2c0e2a97b5bdc53c.tar.gz
cpython-91e33ac3d08a1c6004c469da2c0e2a97b5bdc53c.tar.bz2
bpo-40280: Add requires_fork test helper (GH-30622)
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index a8f3c13..f03a642 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -505,7 +505,7 @@ class ThreadTests(BaseTestCase):
t = threading.Thread(daemon=True)
self.assertTrue(t.daemon)
- @unittest.skipUnless(hasattr(os, 'fork'), 'needs os.fork()')
+ @support.requires_fork()
def test_fork_at_exit(self):
# bpo-42350: Calling os.fork() after threading._shutdown() must
# not log an error.
@@ -533,7 +533,7 @@ class ThreadTests(BaseTestCase):
self.assertEqual(out, b'')
self.assertEqual(err.rstrip(), b'child process ok')
- @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()')
+ @support.requires_fork()
def test_dummy_thread_after_fork(self):
# Issue #14308: a dummy thread in the active list doesn't mess up
# the after-fork mechanism.
@@ -560,7 +560,7 @@ class ThreadTests(BaseTestCase):
self.assertEqual(out, b'')
self.assertEqual(err, b'')
- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ @support.requires_fork()
def test_is_alive_after_fork(self):
# Try hard to trigger #18418: is_alive() could sometimes be True on
# threads that vanished after a fork.
@@ -594,7 +594,7 @@ class ThreadTests(BaseTestCase):
th.start()
th.join()
- @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
+ @support.requires_fork()
@unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()")
def test_main_thread_after_fork(self):
code = """if 1:
@@ -616,7 +616,7 @@ class ThreadTests(BaseTestCase):
self.assertEqual(data, "MainThread\nTrue\nTrue\n")
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
- @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
+ @support.requires_fork()
@unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()")
def test_main_thread_after_fork_from_nonmain_thread(self):
code = """if 1:
@@ -993,7 +993,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
"""
self._run_and_join(script)
- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ @support.requires_fork()
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
def test_2_join_in_forked_process(self):
# Like the test above, but from a forked interpreter
@@ -1014,7 +1014,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
"""
self._run_and_join(script)
- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ @support.requires_fork()
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
def test_3_join_in_forked_from_thread(self):
# Like the test above, but fork() was called from a worker thread
@@ -1085,7 +1085,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
rc, out, err = assert_python_ok('-c', script)
self.assertFalse(err)
- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ @support.requires_fork()
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
def test_reinit_tls_after_fork(self):
# Issue #13817: fork() would deadlock in a multithreaded program with
@@ -1109,7 +1109,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
for t in threads:
t.join()
- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ @support.requires_fork()
def test_clear_threads_states_after_fork(self):
# Issue #17094: check that threads states are cleared after fork()