MCPcopy Index your code
hub / github.com/ipython/ipython / module_not_available

Function module_not_available

IPython/testing/decorators.py:74–89  ·  view source on GitHub ↗

Can module be imported? Returns true if module does NOT import. This is used to make a decorator to skip tests that require module to be available, but delay the 'import numpy' to test execution time.

(module: str)

Source from the content-addressed store, hash-verified

72# -----------------------------------------------------------------------------
73# Utility functions for decorators
74def module_not_available(module: str) -> bool:
75 """Can module be imported? Returns true if module does NOT import.
76
77 This is used to make a decorator to skip tests that require module to be
78 available, but delay the 'import numpy' to test execution time.
79 """
80 try:
81 mod = import_module(module)
82 mod_not_avail = False
83 except Exception:
84 # Catch all exceptions, not just ImportError, since modules can fail
85 # to import for various reasons (e.g., compatibility issues with newer
86 # Python versions causing TypeError, AttributeError, etc.)
87 mod_not_avail = True
88
89 return mod_not_avail
90
91
92# -----------------------------------------------------------------------------

Callers 1

decorators.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…