6
6
import sysconfig
7
7
import time
8
8
import trace
9
+ from typing import NoReturn
9
10
10
11
from test .support import os_helper , MS_WINDOWS , flush_std_streams
11
12
@@ -154,7 +155,7 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
154
155
self .next_single_test : TestName | None = None
155
156
self .next_single_filename : StrPath | None = None
156
157
157
- def log (self , line = '' ):
158
+ def log (self , line : str = '' ) -> None :
158
159
self .logger .log (line )
159
160
160
161
def find_tests (self , tests : TestList | None = None ) -> tuple [TestTuple , TestList | None ]:
@@ -230,11 +231,11 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
230
231
return (tuple (selected ), tests )
231
232
232
233
@staticmethod
233
- def list_tests (tests : TestTuple ):
234
+ def list_tests (tests : TestTuple ) -> None :
234
235
for name in tests :
235
236
print (name )
236
237
237
- def _rerun_failed_tests (self , runtests : RunTests ):
238
+ def _rerun_failed_tests (self , runtests : RunTests ) -> RunTests :
238
239
# Configure the runner to re-run tests
239
240
if self .num_workers == 0 and not self .single_process :
240
241
# Always run tests in fresh processes to have more deterministic
@@ -266,7 +267,7 @@ def _rerun_failed_tests(self, runtests: RunTests):
266
267
self .run_tests_sequentially (runtests )
267
268
return runtests
268
269
269
- def rerun_failed_tests (self , runtests : RunTests ):
270
+ def rerun_failed_tests (self , runtests : RunTests ) -> None :
270
271
if self .python_cmd :
271
272
# Temp patch for https://github.com/python/cpython/issues/94052
272
273
self .log (
@@ -335,7 +336,7 @@ def run_bisect(self, runtests: RunTests) -> None:
335
336
if not self ._run_bisect (runtests , name , progress ):
336
337
return
337
338
338
- def display_result (self , runtests ) :
339
+ def display_result (self , runtests : RunTests ) -> None :
339
340
# If running the test suite for PGO then no one cares about results.
340
341
if runtests .pgo :
341
342
return
@@ -365,7 +366,7 @@ def run_test(
365
366
366
367
return result
367
368
368
- def run_tests_sequentially (self , runtests ) -> None :
369
+ def run_tests_sequentially (self , runtests : RunTests ) -> None :
369
370
if self .coverage :
370
371
tracer = trace .Trace (trace = False , count = True )
371
372
else :
@@ -422,7 +423,7 @@ def run_tests_sequentially(self, runtests) -> None:
422
423
if previous_test :
423
424
print (previous_test )
424
425
425
- def get_state (self ):
426
+ def get_state (self ) -> str :
426
427
state = self .results .get_state (self .fail_env_changed )
427
428
if self .first_state :
428
429
state = f'{ self .first_state } then { state } '
@@ -452,7 +453,7 @@ def finalize_tests(self, coverage: trace.CoverageResults | None) -> None:
452
453
if self .junit_filename :
453
454
self .results .write_junit (self .junit_filename )
454
455
455
- def display_summary (self ):
456
+ def display_summary (self ) -> None :
456
457
duration = time .perf_counter () - self .logger .start_time
457
458
filtered = bool (self .match_tests )
458
459
@@ -466,7 +467,7 @@ def display_summary(self):
466
467
state = self .get_state ()
467
468
print (f"Result: { state } " )
468
469
469
- def create_run_tests (self , tests : TestTuple ):
470
+ def create_run_tests (self , tests : TestTuple ) -> RunTests :
470
471
return RunTests (
471
472
tests ,
472
473
fail_fast = self .fail_fast ,
@@ -674,9 +675,9 @@ def _execute_python(self, cmd, environ):
674
675
f"Command: { cmd_text } " )
675
676
# continue executing main()
676
677
677
- def _add_python_opts (self ):
678
- python_opts = []
679
- regrtest_opts = []
678
+ def _add_python_opts (self ) -> None :
679
+ python_opts : list [ str ] = []
680
+ regrtest_opts : list [ str ] = []
680
681
681
682
environ , keep_environ = self ._add_cross_compile_opts (regrtest_opts )
682
683
if self .ci_mode :
@@ -709,7 +710,7 @@ def _init(self):
709
710
710
711
self .tmp_dir = get_temp_dir (self .tmp_dir )
711
712
712
- def main (self , tests : TestList | None = None ):
713
+ def main (self , tests : TestList | None = None ) -> NoReturn :
713
714
if self .want_add_python_opts :
714
715
self ._add_python_opts ()
715
716
@@ -738,7 +739,7 @@ def main(self, tests: TestList | None = None):
738
739
sys .exit (exitcode )
739
740
740
741
741
- def main (tests = None , _add_python_opts = False , ** kwargs ):
742
+ def main (tests = None , _add_python_opts = False , ** kwargs ) -> NoReturn :
742
743
"""Run the Python suite."""
743
744
ns = _parse_args (sys .argv [1 :], ** kwargs )
744
745
Regrtest (ns , _add_python_opts = _add_python_opts ).main (tests = tests )
0 commit comments