aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_ast
diff options
context:
space:
mode:
authorDaniel Hollas <daniel.hollas@bristol.ac.uk>2025-05-05 23:46:05 +0100
committerGitHub <noreply@github.com>2025-05-05 22:46:05 +0000
commitcae660d6dc0d7ba3f66970ef2f2faf1b93869e91 (patch)
treeb6eac99337845902bf11faa148c37fea83a3075c /Lib/test/test_ast
parentb1aa515bd6b645202eda4ca07e85d92e19b1534d (diff)
downloadcpython-main.tar.gz
cpython-main.zip
gh-118761: Add test_lazy_import for more modules (#133057)HEADmain
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Lib/test/test_ast')
-rw-r--r--Lib/test/test_ast/test_ast.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_ast/test_ast.py b/Lib/test/test_ast/test_ast.py
index 530b5ec428e..09cf3186e05 100644
--- a/Lib/test/test_ast/test_ast.py
+++ b/Lib/test/test_ast/test_ast.py
@@ -26,6 +26,7 @@ from test import support
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", "inspect", "re", "collections", "argparse"})
+
+
class AST_Tests(unittest.TestCase):
maxDiff = None