Skip to content

Commit 8b7db5a

Browse files
authored
bpo-37473: Don't import importlib ASAP in tests (GH-14661)
bpo-15386, bpo-37473: test_import, regrtest and libregrtest no longer import importlib as soon as possible, as the first import, "to test bpo-15386". It is tested by test_import.test_there_can_be_only_one(). Sort test_import imports.
1 parent 1c5e68e commit 8b7db5a

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

Lib/test/libregrtest/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# We import importlib *ASAP* in order to test #15386
2-
import importlib
3-
41
from test.libregrtest.cmdline import _parse_args, RESOURCE_NAMES, ALL_RESOURCES
52
from test.libregrtest.main import main

Lib/test/regrtest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Run this script with -h or --help for documentation.
77
"""
88

9-
# We import importlib *ASAP* in order to test #15386
10-
import importlib
11-
129
import os
1310
import sys
1411
from test.libregrtest import main

Lib/test/test_import/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
# We import importlib *ASAP* in order to test #15386
2-
import importlib
1+
import builtins
2+
import contextlib
3+
import errno
4+
import glob
35
import importlib.util
46
from importlib._bootstrap_external import _get_sourcefile
5-
import builtins
67
import marshal
78
import os
89
import py_compile
910
import random
1011
import shutil
11-
import subprocess
1212
import stat
13+
import subprocess
1314
import sys
15+
import textwrap
1416
import threading
1517
import time
1618
import unittest
17-
import unittest.mock as mock
18-
import textwrap
19-
import errno
20-
import contextlib
21-
import glob
19+
from unittest import mock
2220

2321
import test.support
2422
from test.support import (

0 commit comments

Comments
 (0)