Return the module specified by `module`. In particular: - If `module` is a module, then return module. - If `module` is a string, then import and return the module with that name. - If `module` is None, then return the calling module. The calling module is ass
(module, depth=2)
| 213 | return flags |
| 214 | |
| 215 | def _normalize_module(module, depth=2): |
| 216 | """ |
| 217 | Return the module specified by `module`. In particular: |
| 218 | - If `module` is a module, then return module. |
| 219 | - If `module` is a string, then import and return the |
| 220 | module with that name. |
| 221 | - If `module` is None, then return the calling module. |
| 222 | The calling module is assumed to be the module of |
| 223 | the stack frame at the given depth in the call stack. |
| 224 | """ |
| 225 | if inspect.ismodule(module): |
| 226 | return module |
| 227 | elif isinstance(module, str): |
| 228 | return __import__(module, globals(), locals(), ["*"]) |
| 229 | elif module is None: |
| 230 | try: |
| 231 | try: |
| 232 | return sys.modules[sys._getframemodulename(depth)] |
| 233 | except AttributeError: |
| 234 | return sys.modules[sys._getframe(depth).f_globals['__name__']] |
| 235 | except KeyError: |
| 236 | pass |
| 237 | else: |
| 238 | raise TypeError("Expected a module, string, or None") |
| 239 | |
| 240 | def _load_testfile(filename, package, module_relative, encoding): |
| 241 | if module_relative: |
no test coverage detected
searching dependent graphs…