Hello so I have this aws lambda project in python(3.9) with the next structure:
*root -|
*lambda -|
_init_.py
A.py
*features -|
_init_.py
alexa.feature
B.py
*steps -|
_init_.py
alexa_steps.py
C.py
So following the suggestions I have: In C.py
from importlib import import_module
A = import_module("lambda.A")
def testC():
return A.testA()
If I run C.py it works fine but in alexa_steps.py I got:
from importlib import import_module
@given('the user has opened the skill')
def step_impl(context):
A = import_module("lambda.A")b
A.testA()
In terminal I get into the lambda folder and execute: behave The test fails and I get:
USMCDANCN2Z76AB:mathquiz xzxqdy$ cd lambda
USMCDANCN2Z76AB:lambda xzxqdy$ behave
Exception ModuleNotFoundError: No module named 'lambda'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/behave", line 8, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/__main__.py", line 183, in main
return run_behave(config)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/__main__.py", line 127, in run_behave
failed = runner.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/runner.py", line 804, in run
return self.run_with_paths()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/runner.py", line 809, in run_with_paths
self.load_step_definitions()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/runner.py", line 796, in load_step_definitions
load_step_modules(step_paths)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/runner_util.py", line 412, in load_step_modules
exec_file(os.path.join(path, name), step_module_globals)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/behave/runner_util.py", line 386, in exec_file
exec(code, globals_, locals_)
File "features/steps/C.py", line 2, in <module>
A = import_module("lambda.A")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'lambda'
Thanks in advance for your help