I have a somewhat small project, I broke my project up into different directories to help manage all my files. I am getting around to testing everything right now with pytest and everything runs fine on pycharm. My issue is when uploading this to github actions I get a dreaded ModuleNotFoundError: No module... error. Again all of my tests run in my IDE just not github actions. This is what my import looks like:
from helper_functions import typechecking
def test_force_caps():
test_string = "i'm a test"
output = typechecking.force_caps(test_string)
assert output == "I'M A TEST"
assert len(output) == 10
My file structure is such:
project
-helper_functions # (directory)
--typechecking.py
-test # (directory)
--test_typechecking.py
-main.py
Every time I run this with github action I get:
______ ERROR collecting tests/helper_function_tests/test_typechecking.py _______ ImportError while importing test module '/home/runner/work/Inventory_db/Inventory_db/tests/helper_function_tests/test_typechecking.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/importlib/init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) tests/helper_function_tests/test_typechecking.py:2: in from helper_functions import typechecking E ModuleNotFoundError: No module named 'helper_functions'
I saw a lot of Q and A say to add these to the system path, but found it strange that mine was working just fine, just not through github actions. Do I still need to add it to the path? How do I add it to a path? I tried some solutions but get flake 8 errors and they didn't solve the issue on github actions. Do I simply not test with github actions because they work through pycharm? Is my issue actually with my yaml file?