Skip to content

Conversation

@31413Hao
Copy link
Contributor

Problem

Running pytest tests/ after pip install -e . fails with:

ModuleNotFoundError: No module named 'src'

This is because test_cache.py uses from src.gitfetch.cache import CacheManager, but after editable install, the package name is gitfetch, not src.gitfetch.

Solution

Change the import from:

from src.gitfetch.cache import CacheManager

to:

from gitfetch.cache import CacheManager

Testing

After this fix, all 4 tests in test_cache.py pass:

$ pytest tests/test_cache.py -v
tests/test_cache.py::TestCacheManager::test_cache_expiry PASSED
tests/test_cache.py::TestCacheManager::test_stale_cache_retrieval PASSED
tests/test_cache.py::TestCacheManager::test_cache_minutes_parameter PASSED
tests/test_cache.py::TestCacheManager::test_cache_timestamp_update PASSED

============================== 4 passed ==============================

Change `from src.gitfetch.cache` to `from gitfetch.cache` to fix
ModuleNotFoundError when running tests after `pip install -e .`
@Matars
Copy link
Owner

Matars commented Dec 15, 2025

Thanks

@Matars Matars merged commit 43a3a55 into Matars:main Dec 15, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants