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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 11 additions & 11 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 7 additions & 7 deletions
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

0 commit comments

Comments
 (0)