Skip to content

Commit ff5a757

Browse files
committed
Skip tests when threads aren't available
1 parent e5353d4 commit ff5a757

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Lib/test/test_free_threading/test_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from threading import Thread
44
from unittest import TestCase
55

6-
from test.support import is_wasi
6+
from test.support import threading_helper
77

88

99
class C:
1010
def __init__(self, v):
1111
self.v = v
1212

1313

14-
@unittest.skipIf(is_wasi, "WASI has no threads.")
14+
@threading_helper.requires_working_threading()
1515
class TestList(TestCase):
1616
def test_racing_iter_append(self):
1717

Lib/test/test_free_threading/test_monitoring.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import weakref
88

99
from sys import monitoring
10-
from test.support import is_wasi
10+
from test.support import threading_helper
1111
from threading import Thread
1212
from unittest import TestCase
1313

@@ -93,7 +93,7 @@ def tearDown(self):
9393
monitoring.free_tool_id(self.tool_id)
9494

9595

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

@@ -112,7 +112,7 @@ def after_threads(self):
112112
sys.settrace(self.trace_func)
113113

114114

115-
@unittest.skipIf(is_wasi, "WASI has no threads.")
115+
@threading_helper.requires_working_threading()
116116
class MonitoringMultiThreaded(
117117
MonitoringTestMixin, InstrumentationMultiThreadedMixin, TestCase
118118
):
@@ -146,7 +146,7 @@ def during_threads(self):
146146
self.set = not self.set
147147

148148

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

@@ -172,7 +172,7 @@ def during_threads(self):
172172
self.set = not self.set
173173

174174

175-
@unittest.skipIf(is_wasi, "WASI has no threads.")
175+
@threading_helper.requires_working_threading()
176176
class SetProfileMultiThreaded(InstrumentationMultiThreadedMixin, TestCase):
177177
"""Uses sys.setprofile and repeatedly toggles instrumentation on and off"""
178178
thread_count = 25
@@ -201,7 +201,7 @@ def during_threads(self):
201201
self.set = not self.set
202202

203203

204-
@unittest.skipIf(is_wasi, "WASI has no threads.")
204+
@threading_helper.requires_working_threading()
205205
class MonitoringMisc(MonitoringTestMixin, TestCase):
206206
def register_callback(self):
207207
def callback(*args):

Lib/test/test_free_threading/test_type.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import unittest
22

33
from threading import Thread
4-
from multiprocessing.dummy import Pool
54
from unittest import TestCase
65

7-
from test.support import is_wasi
6+
from test.support import threading_helper, import_helper
87

98

9+
multiprocessing_dummy = import_helper.import_module('multiprocessing.dummy')
10+
Pool = multiprocessing_dummy.Pool
11+
1012
NTHREADS = 6
1113
BOTTOM = 0
1214
TOP = 1000
@@ -15,7 +17,7 @@
1517
class A:
1618
attr = 1
1719

18-
@unittest.skipIf(is_wasi, "WASI has no threads.")
20+
@threading_helper.requires_working_threading()
1921
class TestType(TestCase):
2022
def test_attr_cache(self):
2123
def read(id0):

0 commit comments

Comments
 (0)