diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py index 7cb56ec0c25a7..a6752274efac2 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py @@ -24,7 +24,9 @@ def _load_com_module(): try: return load_module( - "ComInterface", os.path.join(os.path.dirname(__file__), "windows") + "ComInterface", + os.path.join(os.path.dirname(__file__), "windows"), + "ComInterface.py", ) except ImportError as e: raise LoadDebuggerException(e, sys.exc_info()) diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/utils/Imports.py b/cross-project-tests/debuginfo-tests/dexter/dex/utils/Imports.py index ea052c21a1849..cd184f9d20ed8 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/utils/Imports.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/utils/Imports.py @@ -1,12 +1,17 @@ -import importlib +import importlib.util import os import sys -def load_module(name, path): - spec = importlib.util.spec_from_file_location( - name, os.path.join(path, name, "__init__.py") +def load_module(name, path, mod_file="__init__.py"): + # The module is either defined by a directory, in which case we search for + # `path/name/__init__.py`, or it is a single file at `path/mod_file`. + mod_path = ( + os.path.join(path, name, mod_file) + if mod_file == "__init__.py" + else os.path.join(path, mod_file) ) + spec = importlib.util.spec_from_file_location(name, mod_path) module = importlib.util.module_from_spec(spec) sys.modules[name] = module spec.loader.exec_module(module)