Skip to content
10 changes: 10 additions & 0 deletions Lib/test/test_email/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
import time
import unittest

from test.support import cpython_only
from test.support.import_helper import ensure_lazy_imports


class TestImportTime(unittest.TestCase):

@cpython_only
def test_lazy_import(self):
ensure_lazy_imports("email.utils", {"random", "socket"})


class DateTimeTests(unittest.TestCase):

Expand Down
7 changes: 6 additions & 1 deletion Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from pickle import dumps, loads, PicklingError, HIGHEST_PROTOCOL
from test import support
from test.support import ALWAYS_EQ, REPO_ROOT
from test.support import threading_helper
from test.support import threading_helper, cpython_only
from test.support.import_helper import ensure_lazy_imports
from datetime import timedelta

python_version = sys.version_info[:2]
Expand Down Expand Up @@ -1274,6 +1275,10 @@ class Holiday(date, Enum):
IDES_OF_MARCH = 2013, 3, 15
self.Holiday = Holiday

@cpython_only
def test_lazy_import(self):
ensure_lazy_imports("enum", {"functools", "warnings", "inspect", "re"})

def test_bool(self):
# plain Enum members are always True
class Logic(Enum):
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from test.support import import_helper
from test.support import threading_helper
from test.support import cpython_only
from test.support import EqualToForwardRef

import functools
Expand Down Expand Up @@ -63,6 +64,14 @@ def __add__(self, other):
class MyDict(dict):
pass

class TestImportTime(unittest.TestCase):

@cpython_only
def test_lazy_import(self):
import_helper.ensure_lazy_imports(
"functools", {"os", "weakref", "typing", "annotationlib", "warnings"}
)


class TestPartial:

Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from urllib.request import pathname2url

from test.support import import_helper
from test.support import cpython_only
from test.support import is_emscripten, is_wasi
from test.support import infinite_recursion
from test.support import os_helper
Expand Down Expand Up @@ -129,6 +130,7 @@ class StrSubclass(str):
for part in p.parts:
self.assertIs(type(part), str)

@cpython_only
def test_lazy_import(self):
import_helper.ensure_lazy_imports("pathlib", {"shutil"})

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def tearDown(self):
class ThreadTests(BaseTestCase):
maxDiff = 9999

@cpython_only
def test_lazy_import(self):
ensure_lazy_imports("threading", {"functools", "warnings"})

Expand Down
Loading