Skip to content

Commit c3b3a35

Browse files
authored
Make test less expensive
1 parent 3a6f844 commit c3b3a35

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Lib/test/datetimetester.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7295,22 +7295,27 @@ def test_update_type_cache(self):
72957295
""")
72967296
script_helper.assert_python_ok('-c', script)
72977297

7298-
@support.skip_if_pgo_task
72997298
@unittest.skipIf(_interpreters is None, "missing _interpreters module")
73007299
def test_static_type_concurrent_init_fini(self):
73017300
# gh-136421
73027301
script = textwrap.dedent("""
7303-
from concurrent.futures import InterpreterPoolExecutor
7304-
def func():
7305-
import _datetime
7306-
print('a', end='')
7307-
with InterpreterPoolExecutor(max_workers=10) as executor:
7308-
for _ in range(10):
7309-
executor.submit(func)
7310-
""")
7311-
res = script_helper.assert_python_ok("-c", script)
7312-
self.assertEqual(res.out, b'a' * 10)
7313-
self.assertEqual(res.err, b'')
7302+
import threading
7303+
import _interpreters
7304+
7305+
def run(id):
7306+
_interpreters.exec(id, "import _datetime; print('a', end='')")
7307+
_interpreters.destroy(id)
7308+
7309+
ids = [_interpreters.create() for i in range(10)]
7310+
ts = [threading.Thread(target=run, args=(id,)) for id in ids]
7311+
for t in ts:
7312+
t.start()
7313+
for t in ts:
7314+
t.join()
7315+
""")
7316+
_, out, err = script_helper.assert_python_ok('-c', script)
7317+
self.assertEqual(out, b'a' * 10)
7318+
self.assertEqual(err, b'')
73147319

73157320

73167321
def load_tests(loader, standard_tests, pattern):

0 commit comments

Comments
 (0)