For unit testing, I use the structure:
+ my_function/ +- __init__.py - empty files +- code/ +- __init__.py +- lambda_function.py +- unittest/ +- __init__.py +- tests.py - from ..code.lambda_function import *
When doing unit tests with python -m my_function.unittest.tests , lambda_function.py uses __name__ == 'my_function.code.lambda_function'.
When launched in Lambda, __name__ == 'lambda_function'. Note that you will get the same value if you use python -m my_function.code.lambda_function , so you will always need a wrapper.
source share