Skip to content

gh-118362: Skip tests when threading isn't available #118666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/test_free_threading/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from threading import Thread
from unittest import TestCase

from test.support import is_wasi
from test.support import threading_helper


class C:
def __init__(self, v):
self.v = v


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class TestList(TestCase):
def test_racing_iter_append(self):

Expand Down
12 changes: 6 additions & 6 deletions Lib/test/test_free_threading/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import weakref

from sys import monitoring
from test.support import is_wasi
from test.support import threading_helper
from threading import Thread, _PyRLock
from unittest import TestCase

Expand Down Expand Up @@ -87,7 +87,7 @@ def tearDown(self):
monitoring.free_tool_id(self.tool_id)


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class SetPreTraceMultiThreaded(InstrumentationMultiThreadedMixin, TestCase):
"""Sets tracing one time after the threads have started"""

Expand All @@ -106,7 +106,7 @@ def after_threads(self):
sys.settrace(self.trace_func)


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class MonitoringMultiThreaded(
MonitoringTestMixin, InstrumentationMultiThreadedMixin, TestCase
):
Expand Down Expand Up @@ -140,7 +140,7 @@ def during_threads(self):
self.set = not self.set


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class SetTraceMultiThreaded(InstrumentationMultiThreadedMixin, TestCase):
"""Uses sys.settrace and repeatedly toggles instrumentation on and off"""

Expand All @@ -166,7 +166,7 @@ def during_threads(self):
self.set = not self.set


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class SetProfileMultiThreaded(InstrumentationMultiThreadedMixin, TestCase):
"""Uses sys.setprofile and repeatedly toggles instrumentation on and off"""

Expand All @@ -192,7 +192,7 @@ def during_threads(self):
self.set = not self.set


@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class MonitoringMisc(MonitoringTestMixin, TestCase):
def register_callback(self):
def callback(*args):
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/test_free_threading/test_type.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import unittest

from concurrent.futures import ThreadPoolExecutor
from threading import Thread
from multiprocessing.dummy import Pool
from unittest import TestCase

from test.support import is_wasi
from test.support import threading_helper, import_helper



NTHREADS = 6
Expand All @@ -15,7 +16,7 @@
class A:
attr = 1

@unittest.skipIf(is_wasi, "WASI has no threads.")
@threading_helper.requires_working_threading()
class TestType(TestCase):
def test_attr_cache(self):
def read(id0):
Expand All @@ -34,11 +35,10 @@ def write(id0):
A.attr = x


with Pool(NTHREADS) as pool:
pool.apply_async(read, (1,))
pool.apply_async(write, (1,))
pool.close()
pool.join()
with ThreadPoolExecutor(NTHREADS) as pool:
pool.submit(read, (1,))
pool.submit(write, (1,))
pool.shutdown(wait=True)

def test_attr_cache_consistency(self):
class C:
Expand Down