From 3f0cdaee299009edbaa42fe1e276441085525553 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 27 Apr 2025 21:50:50 +0100 Subject: [PATCH 1/6] gh-118761: test_lazy_import for threading and pathlib modules --- Lib/test/test_pathlib/test_pathlib.py | 3 +++ Lib/test/test_threading.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 41a79d0dceb0eb..667ff181e654a4 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -129,6 +129,9 @@ class StrSubclass(str): for part in p.parts: self.assertIs(type(part), str) + def test_lazy_import(self): + import_helper.ensure_lazy_imports("pathlib", {"shutil"}) + def test_str_subclass_common(self): self._check_str_subclass('') self._check_str_subclass('.') diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index fa666608263e27..fceaf97dc379c0 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -5,7 +5,7 @@ import test.support from test.support import threading_helper, requires_subprocess, requires_gil_enabled from test.support import verbose, cpython_only, os_helper -from test.support.import_helper import import_module +from test.support.import_helper import ensure_lazy_imports, import_module from test.support.script_helper import assert_python_ok, assert_python_failure from test.support import force_not_colorized @@ -120,6 +120,9 @@ def tearDown(self): class ThreadTests(BaseTestCase): maxDiff = 9999 + def test_lazy_import(self): + ensure_lazy_imports("threading", {"functools", "warnings"}) + @cpython_only def test_name(self): def func(): pass From 97e8d478f9bf1b686a4e56283f9af194ae2f766b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 28 Apr 2025 01:12:04 +0100 Subject: [PATCH 2/6] Add test_lazy_import for enum, functools, and email.utils --- Lib/test/test_email/test_utils.py | 10 ++++++++++ Lib/test/test_enum.py | 7 ++++++- Lib/test/test_functools.py | 9 +++++++++ Lib/test/test_pathlib/test_pathlib.py | 2 ++ Lib/test/test_threading.py | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_email/test_utils.py b/Lib/test/test_email/test_utils.py index 4e6201e13c87f9..c9d09098b502f9 100644 --- a/Lib/test/test_email/test_utils.py +++ b/Lib/test/test_email/test_utils.py @@ -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): diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 68cedc666a59ef..247a640ee15bfa 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -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] @@ -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): diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 4794a7465f0b66..91e989273e7dc3 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -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 @@ -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: diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 667ff181e654a4..6e35a027d83d2b 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -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 @@ -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"}) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index fceaf97dc379c0..54d2a929f99b19 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -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"}) From 875e0bdd6c20bb3194b66c2c5dc1df169581caf8 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 4 May 2025 20:36:36 +0100 Subject: [PATCH 3/6] Review --- Lib/test/test_enum.py | 8 ++++---- Lib/test/test_pathlib/test_pathlib.py | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 247a640ee15bfa..d8cb5261244939 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -1275,10 +1275,6 @@ 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): @@ -5293,6 +5289,10 @@ class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, enum, not_exported={'bin', 'show_flag_values'}) + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("enum", {"functools", "warnings", "inspect", "re"}) + def test_doc_1(self): class Single(Enum): ONE = 1 diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 6e35a027d83d2b..11d0cffdb3b99e 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -81,6 +81,12 @@ def test_is_notimplemented(self): self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError)) +class TestImportTime(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + import_helper.ensure_lazy_imports("pathlib", {"shutil"}) + + # # Tests for the pure classes. # @@ -130,10 +136,6 @@ 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"}) - def test_str_subclass_common(self): self._check_str_subclass('') self._check_str_subclass('.') From 34e39abfdc1f6e8a825b69c5aac0550fe572d75c Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 5 May 2025 16:55:28 +0100 Subject: [PATCH 4/6] Add test_lazy_import for pickle, mimetypes, base64, csv, pprint and socket modules --- Lib/test/test_base64.py | 8 ++++++++ Lib/test/test_csv.py | 7 ++++++- Lib/test/test_mimetypes.py | 7 ++++++- Lib/test/test_pathlib/test_pathlib.py | 2 +- Lib/test/test_pickle.py | 9 ++++++++- Lib/test/test_pprint.py | 7 +++++++ Lib/test/test_socket.py | 9 ++++++++- 7 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py index 409c8c109e885f..83268f08ac88c4 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -3,8 +3,16 @@ import binascii import os from array import array +from test.support import cpython_only from test.support import os_helper from test.support import script_helper +from test.support.import_helper import ensure_lazy_imports + + +class LazyImportTest(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("base64", {"re"}) class LegacyBase64TestCase(unittest.TestCase): diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index 4af8f7f480e759..9aace57633b0c6 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -10,7 +10,8 @@ import gc import pickle from test import support -from test.support import import_helper, check_disallow_instantiation +from test.support import cpython_only, import_helper, check_disallow_instantiation +from test.support.import_helper import ensure_lazy_imports from itertools import permutations from textwrap import dedent from collections import OrderedDict @@ -1565,6 +1566,10 @@ class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, csv, ('csv', '_csv')) + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("csv", {"re"}) + def test_subclassable(self): # issue 44089 class Foo(csv.Error): ... diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index f2a19c0863570a..fac5684b9d997e 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -6,7 +6,8 @@ import unittest.mock from platform import win32_edition from test import support -from test.support import os_helper +from test.support import cpython_only, os_helper +from test.support.import_helper import ensure_lazy_imports from test.support.script_helper import run_python_until_end try: @@ -409,6 +410,10 @@ class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, mimetypes) + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("mimetypes", {"os", "posixpath", "urllib.parse"}) + class CommandLineTest(unittest.TestCase): def test_parse_args(self): diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 11d0cffdb3b99e..c2e1125e1662c7 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -81,7 +81,7 @@ def test_is_notimplemented(self): self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError)) -class TestImportTime(unittest.TestCase): +class LazyImportTest(unittest.TestCase): @cpython_only def test_lazy_import(self): import_helper.ensure_lazy_imports("pathlib", {"shutil"}) diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 296d4b882e138c..78e65ad017a832 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -15,7 +15,8 @@ import doctest import unittest from test import support -from test.support import import_helper, os_helper +from test.support import cpython_only, import_helper, os_helper +from test.support.import_helper import ensure_lazy_imports from test.pickletester import AbstractHookTests from test.pickletester import AbstractUnpickleTests @@ -36,6 +37,12 @@ has_c_implementation = False +class LazyImportTest(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("pickle", {"re"}) + + class PyPickleTests(AbstractPickleModuleTests, unittest.TestCase): dump = staticmethod(pickle._dump) dumps = staticmethod(pickle._dumps) diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index dfbc2a06e7346f..f68996f72b15b5 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -11,6 +11,9 @@ import types import unittest +from test.support import cpython_only +from test.support.import_helper import ensure_lazy_imports + # list, tuple and dict subclasses that do or don't overwrite __repr__ class list2(list): pass @@ -129,6 +132,10 @@ def setUp(self): self.b = list(range(200)) self.a[-12] = self.b + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("pprint", {"dataclasses", "re"}) + def test_init(self): pp = pprint.PrettyPrinter() pp = pprint.PrettyPrinter(indent=4, width=40, depth=5, diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index e88611ee3147ba..013a2048cb054d 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -2,8 +2,9 @@ from unittest import mock from test import support from test.support import ( - is_apple, os_helper, refleak_helper, socket_helper, threading_helper + cpython_only, is_apple, os_helper, refleak_helper, socket_helper, threading_helper ) +from test.support.import_helper import ensure_lazy_imports import _thread as thread import array import contextlib @@ -257,6 +258,12 @@ def downgrade_malformed_data_warning(): # Size in bytes of the int type SIZEOF_INT = array.array("i").itemsize +class TestLazyImport(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("socket", {"array", "selectors"}) + + class SocketTCPTest(unittest.TestCase): def setUp(self): From eabf651be6553ed6ea5f9f110096e4a47e9103a6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 5 May 2025 18:30:05 +0100 Subject: [PATCH 5/6] Add test_lazy_import for ast, cmd, gettext, locale, optparse, pstats, string and zipfile modules --- Lib/test/test_ast/test_ast.py | 7 +++++++ Lib/test/test_base64.py | 2 +- Lib/test/test_cmd.py | 8 +++++++- Lib/test/test_gettext.py | 7 ++++++- Lib/test/test_locale.py | 9 +++++++-- Lib/test/test_mimetypes.py | 2 +- Lib/test/test_optparse.py | 7 ++++++- Lib/test/test_pstats.py | 7 +++++++ Lib/test/test_shlex.py | 2 ++ Lib/test/test_string/test_string.py | 8 ++++++++ Lib/test/test_zipfile/test_core.py | 9 +++++++++ 11 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py index 6a9b7812ef6185..6e7b8c6c440578 100644 --- a/Lib/test/test_ast/test_ast.py +++ b/Lib/test/test_ast/test_ast.py @@ -26,6 +26,7 @@ from test.support import os_helper from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow from test.support.ast_helper import ASTTestMixin +from test.support.import_helper import ensure_lazy_imports from test.test_ast.utils import to_tuple from test.test_ast.snippets import ( eval_tests, eval_results, exec_tests, exec_results, single_tests, single_results @@ -47,6 +48,12 @@ def ast_repr_update_snapshots() -> None: AST_REPR_DATA_FILE.write_text("\n".join(data)) +class LazyImportTest(unittest.TestCase): + @support.cpython_only + def test_lazy_import(self): + ensure_lazy_imports("ast", {"contextlib", "enum"}) + + class AST_Tests(unittest.TestCase): maxDiff = None diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py index 83268f08ac88c4..9efebc43d911c4 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -12,7 +12,7 @@ class LazyImportTest(unittest.TestCase): @cpython_only def test_lazy_import(self): - ensure_lazy_imports("base64", {"re"}) + ensure_lazy_imports("base64", {"re", "getopt"}) class LegacyBase64TestCase(unittest.TestCase): diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index 0ae44f3987d324..dbfec42fc21988 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -11,9 +11,15 @@ import io import textwrap from test import support -from test.support.import_helper import import_module +from test.support.import_helper import ensure_lazy_imports, import_module from test.support.pty_helper import run_pty +class LazyImportTest(unittest.TestCase): + @support.cpython_only + def test_lazy_import(self): + ensure_lazy_imports("cmd", {"inspect", "string"}) + + class samplecmdclass(cmd.Cmd): """ Instance the sampleclass: diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index 585ed08ea14a55..da7e8b4ba0a3f6 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -6,7 +6,8 @@ from functools import partial from test import support -from test.support import os_helper +from test.support import cpython_only, os_helper +from test.support.import_helper import ensure_lazy_imports # TODO: @@ -931,6 +932,10 @@ def test__all__(self): support.check__all__(self, gettext, not_exported={'c2py', 'ENOENT'}) + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("gettext", {"re"}) + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index 528ceef528114c..23bdbe43b8e3ff 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -1,13 +1,18 @@ from decimal import Decimal -from test.support import verbose, is_android, linked_to_musl, os_helper +from test.support import cpython_only, verbose, is_android, linked_to_musl, os_helper from test.support.warnings_helper import check_warnings -from test.support.import_helper import import_fresh_module +from test.support.import_helper import ensure_lazy_imports, import_fresh_module from unittest import mock import unittest import locale import sys import codecs +class LazyImportTest(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("locale", {"re"}) + class BaseLocalizedTest(unittest.TestCase): # diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 640e5ae076cc83..5faebd81cc9552 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -438,7 +438,7 @@ def test__all__(self): @cpython_only def test_lazy_import(self): - ensure_lazy_imports("mimetypes", {"os", "posixpath", "urllib.parse"}) + ensure_lazy_imports("mimetypes", {"os", "posixpath", "urllib.parse", "argparse"}) class CommandLineTest(unittest.TestCase): diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index 8655a0537a5e56..e6ffd2b0ffeb0e 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -14,8 +14,9 @@ from io import StringIO from test import support -from test.support import os_helper +from test.support import cpython_only, os_helper from test.support.i18n_helper import TestTranslationsBase, update_translation_snapshots +from test.support.import_helper import ensure_lazy_imports import optparse from optparse import make_option, Option, \ @@ -1655,6 +1656,10 @@ def test__all__(self): not_exported = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'} support.check__all__(self, optparse, not_exported=not_exported) + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("optparse", {"textwrap"}) + class TestTranslations(TestTranslationsBase): def test_translations(self): diff --git a/Lib/test/test_pstats.py b/Lib/test/test_pstats.py index d5a5a9738c2498..a26a8c1d522a70 100644 --- a/Lib/test/test_pstats.py +++ b/Lib/test/test_pstats.py @@ -1,6 +1,7 @@ import unittest from test import support +from test.support.import_helper import ensure_lazy_imports from io import StringIO from pstats import SortKey from enum import StrEnum, _test_simple_enum @@ -10,6 +11,12 @@ import tempfile import cProfile +class LazyImportTest(unittest.TestCase): + @support.cpython_only + def test_lazy_import(self): + ensure_lazy_imports("pstats", {"typing"}) + + class AddCallersTestCase(unittest.TestCase): """Tests for pstats.add_callers helper.""" diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index f35571ea88654d..a13ddcb76b7bcb 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -3,6 +3,7 @@ import shlex import string import unittest +from test.support import cpython_only from test.support import import_helper @@ -364,6 +365,7 @@ def testPunctuationCharsReadOnly(self): with self.assertRaises(AttributeError): shlex_instance.punctuation_chars = False + @cpython_only def test_lazy_imports(self): import_helper.ensure_lazy_imports('shlex', {'collections', 're', 'os'}) diff --git a/Lib/test/test_string/test_string.py b/Lib/test/test_string/test_string.py index f6d112d8a93ec4..5394fe4e12cd41 100644 --- a/Lib/test/test_string/test_string.py +++ b/Lib/test/test_string/test_string.py @@ -2,6 +2,14 @@ import string from string import Template import types +from test.support import cpython_only +from test.support.import_helper import ensure_lazy_imports + + +class LazyImportTest(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("base64", {"re", "collections"}) class ModuleTest(unittest.TestCase): diff --git a/Lib/test/test_zipfile/test_core.py b/Lib/test/test_zipfile/test_core.py index 7c8a82d821a020..4c9d9f4b56235d 100644 --- a/Lib/test/test_zipfile/test_core.py +++ b/Lib/test/test_zipfile/test_core.py @@ -24,10 +24,12 @@ from test.support import ( findfile, requires_zlib, requires_bz2, requires_lzma, captured_stdout, captured_stderr, requires_subprocess, + cpython_only ) from test.support.os_helper import ( TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count, FakePath ) +from test.support.import_helper import ensure_lazy_imports TESTFN2 = TESTFN + "2" @@ -49,6 +51,13 @@ def get_files(test): yield f test.assertFalse(f.closed) + +class LazyImportTest(unittest.TestCase): + @cpython_only + def test_lazy_import(self): + ensure_lazy_imports("zipfile", {"typing"}) + + class AbstractTestsWithSourceFile: @classmethod def setUpClass(cls): From 4628f144ec86d82e8f986dc4a023c2b1f28cfeb4 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 5 May 2025 22:14:39 +0100 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Jelle Zijlstra --- Lib/test/test_ast/test_ast.py | 2 +- Lib/test/test_gettext.py | 2 +- Lib/test/test_locale.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py index 6e7b8c6c440578..a2e67a0aa0907a 100644 --- a/Lib/test/test_ast/test_ast.py +++ b/Lib/test/test_ast/test_ast.py @@ -51,7 +51,7 @@ def ast_repr_update_snapshots() -> None: class LazyImportTest(unittest.TestCase): @support.cpython_only def test_lazy_import(self): - ensure_lazy_imports("ast", {"contextlib", "enum"}) + ensure_lazy_imports("ast", {"contextlib", "enum", "inspect", "re", "collections", "argparse"}) class AST_Tests(unittest.TestCase): diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index da7e8b4ba0a3f6..33b7d75e3ff203 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -934,7 +934,7 @@ def test__all__(self): @cpython_only def test_lazy_import(self): - ensure_lazy_imports("gettext", {"re"}) + ensure_lazy_imports("gettext", {"re", "warnings", "locale"}) if __name__ == '__main__': diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index 23bdbe43b8e3ff..455d2af37efdc8 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -11,7 +11,7 @@ class LazyImportTest(unittest.TestCase): @cpython_only def test_lazy_import(self): - ensure_lazy_imports("locale", {"re"}) + ensure_lazy_imports("locale", {"re", "warnings"}) class BaseLocalizedTest(unittest.TestCase): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy