8000 gh-108416: Mark slow but not CPU bound test methods with requires_res… · vstinner/cpython@2cf86ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cf86ef

Browse files
serhiy-storchakavstinner
authored andcommitted
pythongh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (pythonGH-108480)
(cherry picked from commit 1e0d627)
1 parent 4f7e7b9 commit 2cf86ef

18 files changed

+48
-3
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ def test_close(self):
675675

676676
close_queue(q)
677677

678+
@support.requires_resource('walltime')
678679
def test_many_processes(self):
679680
if self.TYPE == 'threads':
680681
self.skipTest('test not appropriate for {}'.format(self.TYPE))
@@ -4953,6 +4954,7 @@ def test_wait_slow(self):
49534954
def test_wait_socket_slow(self):
49544955
self.test_wait_socket(True)
49554956

4957+
@support.requires_resource('walltime')
49564958
def test_wait_timeout(self):
49574959
from multiprocessing.connection import wait
49584960

@@ -4981,6 +4983,7 @@ def signal_and_sleep(cls, sem, period):
49814983
sem.release()
49824984
time.sleep(period)
49834985

4986+
@support.requires_resource('walltime')
49844987
def test_wait_integer(self):
49854988
from multiprocessing.connection import wait
49864989

Lib/test/libregrtest/cmdline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
108108
cpu - Used for certain CPU-heavy tests.
109109
110+
walltime - Long running but not CPU-bound tests.
111+
110112
subprocess Run all tests for the subprocess module.
111113
112114
urlfetch - It is okay to download files required on testing.
@@ -129,7 +131,7 @@
129131

130132

131133
ALL_RESOURCES = ('audio', 'curses', 'largefile', 'network',
132-
'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui')
134+
'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui', 'walltime')
133135

134136
# Other resources excluded from --use=all:
135137
#

Lib/test/test_concurrent_futures/executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_map_exception(self):
5353
self.assertEqual(i.__next__(), (0, 1))
5454
self.assertRaises(ZeroDivisionError, i.__next__)
5555

56+
@support.requires_resource('walltime')
5657
def test_map_timeout(self):
5758
results = []
5859
try:

Lib/test/test_concurrent_futures/test_wait.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import time
44
import unittest
55
from concurrent import futures
6+
from test import support
67

78
from .util import (
89
CANCELLED_FUTURE, CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE,
@@ -53,6 +54,7 @@ def test_first_completed_some_already_completed(self):
5354
finished)
5455
self.assertEqual(set([future1]), pending)
5556

57+
@support.requires_resource('walltime')
5658
def test_first_exception(self):
5759
future1 = self.executor.submit(mul, 2, 21)
5860
future2 = self.executor.submit(sleep_and_raise, 1.5)
@@ -110,6 +112,7 @@ def test_all_completed(self):
110112
future2]), finished)
111113
self.assertEqual(set(), pending)
112114

115+
@support.requires_resource('walltime')
113116
def test_timeout(self):
114117
future1 = self.executor.submit(mul, 6, 7)
115118
future2 = self.executor.submit(time.sleep, 6)

Lib/test/test_eintr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class EINTRTests(unittest.TestCase):
1010

1111
@unittest.skipUnless(hasattr(signal, "setitimer"), "requires setitimer()")
12+
@support.requires_resource('walltime')
1213
def test_all(self):
1314
# Run the tester in a sub-process, to make sure there is only one
1415
# thread (for reliable signal delivery).

Lib/test/test_faulthandler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ def test_dump_traceback_later_fd(self):
676676
with tempfile.TemporaryFile('wb+') as fp:
677677
self.check_dump_traceback_later(fd=fp.fileno())
678678

679+
@support.requires_resource('walltime')
679680
def test_dump_traceback_later_twice(self):
680681
self.check_dump_traceback_later(loops=2)
681682

Lib/test/test_httplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,7 @@ def test_networked_good_cert(self):
19541954
h.close()
19551955
self.assertIn('nginx', server_string)
19561956

1957+
@support.requires_resource('walltime')
19571958
def test_networked_bad_cert(self):
19581959
# We feed a "CA" cert that is unrelated to the server's cert
19591960
import ssl

Lib/test/test_imaplib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import threading
1111
import socket
1212

13-
from test.support import verbose, run_with_tz, run_with_locale, cpython_only
13+
from test.support import verbose, run_with_tz, run_with_locale, cpython_only, requires_resource
1414
from test.support import hashlib_helper
1515
from test.support import threading_helper
1616
import unittest
@@ -456,6 +456,7 @@ def test_simple_with_statement(self):
456456
with self.imap_class(*server.server_address):
457457
pass
458458

459+
@requires_resource('walltime')
459460
def test_imaplib_timeout_test(self):
460461
_, server = self._setup(SimpleIMAPHandler)
461462
addr = server.server_address[1]
@@ -549,6 +550,7 @@ class NewIMAPSSLTests(NewIMAPTestsMixin, unittest.TestCase):
549550
imap_class = IMAP4_SSL
550551
server_class = SecureTCPServer
551552

553+
@requires_resource('walltime')
552554
def test_ssl_raises(self):
553555
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
554556
self.assertEqual(ssl_context.verify_mode, ssl.CERT_REQUIRED)
@@ -563,6 +565,7 @@ def test_ssl_raises(self):
563565
ssl_context=ssl_context)
564566
client.shutdown()
565567

568+
@requires_resource('walltime')
566569
def test_ssl_verified(self):
567570
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
568571
ssl_context.load_verify_locations(CAFILE)

Lib/test/test_io.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,10 +4478,12 @@ def run():
44784478
self.assertFalse(err.strip('.!'))
44794479

44804480
@threading_helper.requires_working_threading()
4481+
@support.requires_resource('walltime')
44814482
def test_daemon_threads_shutdown_stdout_deadlock(self):
44824483
self.check_daemon_threads_shutdown_deadlock('stdout')
44834484

44844485
@threading_helper.requires_working_threading()
4486+
@support.requires_resource('walltime')
44854487
def test_daemon_threads_shutdown_stderr_deadlock(self):
44864488
self.check_daemon_threads_shutdown_deadlock('stderr')
44874489

@@ -4655,11 +4657,13 @@ def alarm_handler(sig, frame):
46554657
os.close(r)
46564658

46574659
@requires_alarm
4660+
@support.requires_resource('walltime')
46584661
def test_interrupted_read_retry_buffered(self):
46594662
self.check_interrupted_read_retry(lambda x: x.decode('latin1'),
46604663
mode="rb")
46614664

46624665
@requires_alarm
4666+
@support.requires_resource('walltime')
46634667
def test_interrupted_read_retry_text(self):
46644668
self.check_interrupted_read_retry(lambda x: x,
46654669
mode="r", encoding="latin1")
@@ -4733,10 +4737,12 @@ def alarm2(sig, frame):
47334737
raise
47344738

47354739
@requires_alarm
4740+
@support.requires_resource('walltime')
47364741
def test_interrupted_write_retry_buffered(self):
47374742
self.check_interrupted_write_retry(b"x", mode="wb")
47384743

47394744
@requires_alarm
4745+
@support.requires_resource('walltime')
47404746
def test_interrupted_write_retry_text(self):
47414747
self.check_interrupted_write_retry("x", mode="w", encoding="latin1")
47424748

Lib/test/test_logging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ def test_path_objects(self):
680680
support.is_emscripten, "Emscripten cannot fstat unlinked files."
681681
)
682682
@threading_helper.requires_working_threading()
683+
@support.requires_resource('walltime')
683684
def test_race(self):
684685
# Issue #14632 refers.
685686
def remove_loop(fname, tries):

0 commit comments

Comments
 (0)
0