Skip to content

Commit

Permalink
pythongh-124402: Require cpu resource in test_free_threading (python#…
Browse files Browse the repository at this point in the history
…124438)

Require the 'cpu' test resource on slow test_free_threading tests.

(cherry picked from commit 38a5beb)
  • Loading branch information
vstinner committed Sep 24, 2024
1 parent e9b00cc commit 17555f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lib/test/test_free_threading/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from threading import Thread
from unittest import TestCase

from test import support
from test.support import threading_helper


Expand All @@ -13,6 +14,7 @@ def __init__(self, v):

@threading_helper.requires_working_threading()
class TestList(TestCase):
@support.requires_resource('cpu')
def test_racing_iter_append(self):

l = []
Expand Down Expand Up @@ -42,6 +44,7 @@ def reader_func():
for reader in readers:
reader.join()

@support.requires_resource('cpu')
def test_racing_iter_extend(self):
iters = [
lambda x: [x],
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_free_threading/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import weakref

from sys import monitoring
from test import support
from test.support import threading_helper
from threading import Thread, _PyRLock
from unittest import TestCase
Expand Down Expand Up @@ -43,6 +44,7 @@ def after_test(self):
"""Runs once after the test is done"""
pass

@support.requires_resource('cpu')
def test_instrumentation(self):
# Setup a bunch of functions which will need instrumentation...
funcs = []
Expand Down Expand Up @@ -218,6 +220,7 @@ def test_register_callback(self):
for ref in self.refs:
self.assertEqual(ref(), None)

@support.requires_resource('cpu')
def test_set_local_trace_opcodes(self):
def trace(frame, event, arg):
frame.f_trace_opcodes = True
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_free_threading/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from threading import Thread
from unittest import TestCase

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


Expand Down Expand Up @@ -96,6 +97,7 @@ def reader_func():

self.run_one(writer_func, reader_func)

@support.requires_resource('cpu')
def test___class___modification(self):
class Foo:
pass
Expand Down

0 comments on commit 17555f5

Please sign in to comment.