Just set up my new macbook and I am having importIssues running my python tests.
pytest --cov-config=.coveragerc --cov=main tests
I get the error:
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_rds_config.py:6: in <module>
from main import rds_config
E ModuleNotFoundError: No module named 'main'
Running the same tests on my old laptop works fine. Some people have said I need to do something with my PYTHONPATH but I am not sure what to do. I have installed python 3.9 using brew.
Also, running the test in pycharm by pressing the run button also works fine. So it is not working only in the terminal.
- File structure:
- Project
- main
- lambda_function
- rds_config
- tests
- test_lambda_function
- test_rds_config
- main
- Project
How I am importing:
from main import lambda_function