Someone was very helpful earlier here: Persistent ModuleNotFoundError: No module named 'src' in Python Project and explained how to use modern technology and make better project structures. I've added more scripts and tests to my repo only to encounter the same issue again.
This already looks suspicious to me. Not only does default
exist already (why?) but also the icon looks wrong when entering hatch shell
.
After pip install -e .
finishes without further error, I run pytest
to run into this problem:
_________ ERROR collecting tests/provider/test_dump_csv.py
ImportError while importing test module 'G:\hyperMVP\tests\provider\test_dump_csv.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests\provider\test_dump_csv.py:4: in <module>
from src.hypermvp.provider.loader import load_provider_file
E ModuleNotFoundError: No module named 'src'
_________________________________________________ ERROR collecting tests/provider/test_save_to_duckdb.py ____________________________________
ImportError while importing test module 'G:\hyperMVP\tests\provider\test_save_to_duckdb.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests\provider\test_save_to_duckdb.py:5: in <module>
from src.hypermvp.provider.save_to_duckdb import save_to_duckdb
E ModuleNotFoundError: No module named 'src'
=================================================== short test summary info =============================================================
ERROR tests/provider/test_dump_csv.py
ERROR tests/provider/test_save_to_duckdb.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================= 2 errors in 4.71s =================================================
What's going on here?
A colleague from work answered the question for me. The answer is clearly PEBKAC... I deleted a module/script which is still being called from the unittests. The module merger.py
was deleted.
It was my own PTSD from the last incident that I have to deal with this all over again which prevented me from taking it step-by-step. He showed me how to follow the white rabbit by checking which commit had the first failed unittests. then checked the diffs in the commit where I then screamed "AHHH, I deleted the module which is trying to be imported from"
In hindsight: stress and anxienty are a hinderance when analyzing ones own issues. Little experience and carelessly deleting stuff on the repo without using tools that warn about imports from files you are deleting, are also a bad idea.