diff --git a/tests/conftest.py b/tests/conftest.py index f50a313..de58e0f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,8 +29,17 @@ def load_handler(relative_path, module_name): across Lambdas. The same loader serves the ``ses_auth.py`` modules, which are likewise duplicated per pipeline and not importable as packages. + + The Lambda runtime puts each function's own directory on ``sys.path``, + so handler modules import their siblings by bare name (e.g. + ``from ses_auth import authenticate_inbound_email``). The function + directory is added to ``sys.path`` here so the module executes the + same way under test as it does in the Lambda. """ path = REPO_ROOT / relative_path + package_dir = str(path.parent) + if package_dir not in sys.path: + sys.path.insert(0, package_dir) spec = importlib.util.spec_from_file_location(module_name, path) module = importlib.util.module_from_spec(spec) sys.modules[module_name] = module