diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 46b29650d9383b5..0a4964ce4b98cc5 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -24,8 +24,9 @@ import sys from urllib.error import URLError import urllib.request -from test.support import os_helper +from test.support import cpython_only, os_helper from test.support import findfile, check__all__ +from test.support import import_helper from test.support.os_helper import FakePath, TESTFN @@ -1600,6 +1601,12 @@ def test_deprecated__version__and__date__(self): getattr(module, "version") self.assertEqual(cm.filename, __file__) + @cpython_only + def test_lazy_import(self): + import_helper.ensure_lazy_imports( + "xml.sax.saxutils", {"urllib.parse", "urllib.request"} + ) + if __name__ == "__main__": unittest.main() diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index 920283c3f3496f0..4bdfff1b9b8bc12 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -3,7 +3,9 @@ convenience of application and driver writers. """ -import os, urllib.parse, urllib.request +import os +lazy import urllib.parse +lazy import urllib.request import io import codecs from . import handler