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)
| 72 | # ----------------------------------------------------------------------------- |
| 73 | # Utility functions for decorators |
| 74 | def 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 | # ----------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected
searching dependent graphs…