Skip to content

Commit 7aa8fcc

Browse files
authored
gh-109162: libregrtest: use relative imports (#109250)
libregrtest.__init__ no longer exposes any symbol, so "python -m test.libregrtest.worker" imports less modules.
1 parent 0c139b5 commit 7aa8fcc

17 files changed

+110
-105
lines changed

Lib/test/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from test.libregrtest import main
1+
from test.libregrtest.main import main
22
main()

Lib/test/autotest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This should be equivalent to running regrtest.py from the cmdline.
22
# It can be especially handy if you're in an interactive shell, e.g.,
33
# from test import autotest.
4-
from test.libregrtest import main
4+
from test.libregrtest.main import main
55
main()

Lib/test/libregrtest/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
from test.libregrtest.cmdline import _parse_args, RESOURCE_NAMES, ALL_RESOURCES
2-
from test.libregrtest.main import main

Lib/test/libregrtest/findtests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from test.libregrtest.utils import StrPath, TestName, TestList
3+
from .utils import StrPath, TestName, TestList
44

55

66
# If these test directories are encountered recurse into them and treat each

Lib/test/libregrtest/logger.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
22
import time
33

4-
from test.libregrtest.results import TestResults
5-
from test.libregrtest.runtests import RunTests
6-
from test.libregrtest.utils import print_warning, MS_WINDOWS
4+
from .results import TestResults
5+
from .runtests import RunTests
6+
from .utils import print_warning, MS_WINDOWS
77

88
if MS_WINDOWS:
9-
from test.libregrtest.win_utils import WindowsLoadTracker
9+
from .win_utils import WindowsLoadTracker
1010

1111

1212
class Logger:

Lib/test/libregrtest/main.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
from test import support
1111
from test.support import os_helper
1212

13-
from test.libregrtest.cmdline import _parse_args, Namespace
14-
from test.libregrtest.findtests import findtests, split_test_packages
15-
from test.libregrtest.logger import Logger
16-
from test.libregrtest.result import State
17-
from test.libregrtest.runtests import RunTests, HuntRefleak
18-
from test.libregrtest.setup import setup_process, setup_test_dir
19-
from test.libregrtest.single import run_single_test, PROGRESS_MIN_TIME
20-
from test.libregrtest.pgo import setup_pgo_tests
21-
from test.libregrtest.results import TestResults
22-
from test.libregrtest.utils import (
13+
from .cmdline import _parse_args, Namespace
14+
from .findtests import findtests, split_test_packages
15+
from .logger import Logger
16+
from .result import State
17+
from .runtests import RunTests, HuntRefleak
18+
from .setup import setup_process, setup_test_dir
19+
from .single import run_single_test, PROGRESS_MIN_TIME
20+
from .pgo import setup_pgo_tests
21+
from .results import TestResults
22+
from .utils import (
2323
StrPath, StrJSON, TestName, TestList, TestTuple, FilterTuple,
2424
strip_py_suffix, count, format_duration,
2525
printlist, get_build_info, get_temp_dir, get_work_dir, exit_timeout,
@@ -409,7 +409,7 @@ def get_state(self):
409409
return state
410410

411411
def _run_tests_mp(self, runtests: RunTests, num_workers: int) -> None:
412-
from test.libregrtest.run_workers import RunWorkers
412+
from .run_workers import RunWorkers
413413
RunWorkers(num_workers, runtests, self.logger, self.results).run()
414414

415415
def finalize_tests(self, tracer):

Lib/test/libregrtest/refleak.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from test import support
66
from test.support import os_helper
77

8-
from test.libregrtest.runtests import HuntRefleak
9-
from test.libregrtest.utils import clear_caches
8+
from .runtests import HuntRefleak
9+
from .utils import clear_caches
1010

1111
try:
1212
from _abc import _get_dump

Lib/test/libregrtest/result.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from test.support import TestStats
66

7-
from test.libregrtest.utils import (
7+
from .utils import (
88
StrJSON, TestName, FilterTuple,
99
format_duration, normalize_test_name, print_warning)
1010

Lib/test/libregrtest/results.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sys
22
from test.support import TestStats
33

4-
from test.libregrtest.runtests import RunTests
5-
from test.libregrtest.result import State, TestResult
6-
from test.libregrtest.utils import (
4+
from .runtests import RunTests
5+
from .result import State, TestResult
6+
from .utils import (
77
StrPath, TestName, TestTuple, TestList, FilterDict,
88
printlist, count, format_duration)
99

Lib/test/libregrtest/run_workers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
from test import support
1515
from test.support import os_helper
1616

17-
from test.libregrtest.logger import Logger
18-
from test.libregrtest.result import TestResult, State
19-
from test.libregrtest.results import TestResults
20-
from test.libregrtest.runtests import RunTests
21-
from test.libregrtest.single import PROGRESS_MIN_TIME
22-
from test.libregrtest.utils import (
17+
from .logger import Logger
18+
from .result import TestResult, State
19+
from .results import TestResults
20+
from .runtests import RunTests
21+
from .single import PROGRESS_MIN_TIME
22+
from .utils import (
2323
StrPath, TestName,
2424
format_duration, print_warning)
25-
from test.libregrtest.worker import create_worker_process, USE_PROCESS_GROUP
25+
from .worker import create_worker_process, USE_PROCESS_GROUP
2626

2727
if sys.platform == 'win32':
2828
import locale

Lib/test/libregrtest/runtests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
from typing import Any
44

5-
from test.libregrtest.utils import (
5+
from .utils import (
66
StrPath, StrJSON, TestTuple, FilterTuple, FilterDict)
77

88

Lib/test/libregrtest/save_env.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import os
44
import sys
55
import threading
6+
67
from test import support
78
from test.support import os_helper
8-
from test.libregrtest.utils import print_warning
9+
10+
from .utils import print_warning
911

1012

1113
class SkipTestEnvironment(Exception):

Lib/test/libregrtest/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
except ImportError:
1111
gc = None
1212

13-
from test.libregrtest.runtests import RunTests
14-
from test.libregrtest.utils import (
13+
from .runtests import RunTests
14+
from .utils import (
1515
setup_unraisable_hook, setup_threading_excepthook, fix_umask,
1616
replace_stdout, adjust_rlimit_nofile)
1717

Lib/test/libregrtest/single.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from test.support import TestStats
1313
from test.support import threading_helper
1414

15-
from test.libregrtest.result import State, TestResult
16-
from test.libregrtest.runtests import RunTests
17-
from test.libregrtest.save_env import saved_test_environment
18-
from test.libregrtest.setup import setup_tests
19-
from test.libregrtest.utils import (
15+
from .result import State, TestResult
16+
from .runtests import RunTests
17+
from .save_env import saved_test_environment
18+
from .setup import setup_tests
19+
from .utils import (
2020
TestName,
2121
clear_caches, remove_testfn, abs_module_name, print_warning)
2222

@@ -40,7 +40,7 @@ def regrtest_runner(result: TestResult, test_func, runtests: RunTests) -> None:
4040
# Run test_func(), collect statistics, and detect reference and memory
4141
# leaks.
4242
if runtests.hunt_refleak:
43-
from test.libregrtest.refleak import runtest_refleak
43+
from .refleak import runtest_refleak
4444
refleak, test_result = runtest_refleak(result.test_name, test_func,
4545
runtests.hunt_refleak,
4646
runtests.quiet)

Lib/test/libregrtest/worker.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from test import support
77
from test.support import os_helper
88

9-
from test.libregrtest.setup import setup_process, setup_test_dir
10-
from test.libregrtest.runtests import RunTests
11-
from test.libregrtest.single import run_single_test
12-
from test.libregrtest.utils import (
9+
from .setup import setup_process, setup_test_dir
10+
from .runtests import RunTests
11+
from .single import run_single_test
12+
from .utils import (
1313
StrPath, StrJSON, FilterTuple,
1414
get_work_dir, exit_timeout)
1515

Lib/test/regrtest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import os
1010
import sys
11-
from test.libregrtest import main
11+
from test.libregrtest.main import main
1212

1313

1414
# Alias for backward compatibility (just in case)

0 commit comments

Comments
 (0)