MCPcopy Index your code
hub / github.com/RustPython/RustPython / import_module

Function import_module

Lib/test/support/import_helper.py:69–84  ·  view source on GitHub ↗

Import and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed. If a module is required on a platform but optional for others, set required_on to an iterable of platform prefixe

(name, deprecated=False, *, required_on=())

Source from the content-addressed store, hash-verified

67
68
69def import_module(name, deprecated=False, *, required_on=()):
70 """Import and return the module to be tested, raising SkipTest if
71 it is not available.
72
73 If deprecated is True, any module or package deprecation messages
74 will be suppressed. If a module is required on a platform but optional for
75 others, set required_on to an iterable of platform prefixes which will be
76 compared against sys.platform.
77 """
78 with _ignore_deprecated_imports(deprecated):
79 try:
80 return importlib.import_module(name)
81 except ImportError as msg:
82 if sys.platform.startswith(tuple(required_on)):
83 raise
84 raise unittest.SkipTest(str(msg))
85
86
87def _save_and_remove_modules(names):

Callers 15

test_tty.pyFile · 0.90
test_refcount_errorsMethod · 0.90
test_opcache.pyFile · 0.90
test_asyncgen.pyFile · 0.90
test_c_classMethod · 0.90
detach_readlineMethod · 0.90
test_mmap.pyFile · 0.90
test_ioctl.pyFile · 0.90
test_zstd.pyFile · 0.90
test_fcntl.pyFile · 0.90

Calls 4

strFunction · 0.85
import_moduleMethod · 0.45
startswithMethod · 0.45