Skip to content

Commit a66a331

Browse files
committed
Move test to test_free_threading.test_sys
1 parent 19e863c commit a66a331

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

Lib/test/libregrtest/tsan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
'test_socket',
2121
'test_sqlite3',
2222
'test_ssl',
23-
'test_sys',
2423
'test_syslog',
2524
'test_thread',
2625
'test_thread_local_bytecode',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
import unittest
3+
from test.support import threading_helper
4+
5+
6+
class SysModuleTest(unittest.TestCase):
7+
def test_int_max_str_digits_thread(self):
8+
# gh-151218: Check that it's safe to call set_int_max_str_digits()
9+
# in parallel. Previously, this test triggered warnings in TSan
10+
# on a free threaded build.
11+
12+
old_limit = sys.get_int_max_str_digits()
13+
self.addCleanup(sys.set_int_max_str_digits, old_limit)
14+
15+
def worker():
16+
for i in range (20_000):
17+
sys.set_int_max_str_digits(4300 + (i & 7))
18+
19+
threading_helper.run_concurrently(worker, nthreads=4)
20+
21+
22+
if __name__ == "__main__":
23+
unittest.main()

Lib/test/test_sys.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,20 +1369,6 @@ def test_int_max_str_digits(self):
13691369
with self.assertRaises(TypeError):
13701370
sys.set_int_max_str_digits(2_048.0)
13711371

1372-
def test_int_max_str_digits_thread(self):
1373-
# gh-151218: Check that it's safe to call set_int_max_str_digits()
1374-
# in parallel. Previously, this test triggered warnings in TSan
1375-
# on a free threaded build.
1376-
1377-
old_limit = sys.get_int_max_str_digits()
1378-
self.addCleanup(sys.set_int_max_str_digits, old_limit)
1379-
1380-
def worker():
1381-
for i in range (20_000):
1382-
sys.set_int_max_str_digits(4300 + (i & 7))
1383-
1384-
threading_helper.run_concurrently(worker, nthreads=4)
1385-
13861372

13871373
@test.support.cpython_only
13881374
@test.support.force_not_colorized_test_class

0 commit comments

Comments
 (0)